Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gin-3269548
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
gin-3269548
Commits
ccafcd51
Commit
ccafcd51
authored
2 years ago
by
Sascha Eggenberger
Browse files
Options
Downloads
Patches
Plain Diff
Fix breadcrumb for entitites
parent
f12543d1
No related branches found
Tags
previous/3365180-pm-warnings-for-2x/2024-06-26
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
includes/breadcrumb.theme
+27
-6
27 additions, 6 deletions
includes/breadcrumb.theme
with
27 additions
and
6 deletions
includes/breadcrumb.theme
+
27
−
6
View file @
ccafcd51
...
...
@@ -19,10 +19,12 @@ function gin_preprocess_breadcrumb(&$variables) {
$entity_id
=
$entity
?
$entity
->
getEntityTypeId
()
:
NULL
;
$url
=
$entity
?
$entity
->
toUrl
()
->
toString
()
:
NULL
;
if
(
$item
[
'url'
]
===
'/'
)
{
// Back to site item.
if
(
$key
===
0
)
{
$variables
[
'breadcrumb'
][
$key
][
'text'
]
=
t
(
'Back to site'
);
$variables
[
'breadcrumb'
][
$key
][
'attributes'
][
'title'
]
=
t
(
'Return to site content'
);
// Media handling.
if
(
$entity_id
===
'media'
)
{
$config
=
\Drupal
::
config
(
'media.settings'
);
...
...
@@ -34,6 +36,7 @@ function gin_preprocess_breadcrumb(&$variables) {
}
}
// Check for entity $url.
if
(
$url
)
{
$variables
[
'breadcrumb'
][
$key
][
'url'
]
=
$url
;
}
...
...
@@ -46,15 +49,33 @@ function gin_preprocess_breadcrumb(&$variables) {
// Remove as we already have the back to site link set.
unset
(
$variables
[
'breadcrumb'
][
$key
]);
}
elseif
(
$item
[
'url'
]
===
'/node'
)
{
if
(
$node
=
\Drupal
::
routeMatch
()
->
getParameter
(
'node'
))
{
if
(
$node
instanceof
NodeInterface
)
{
$variables
[
'breadcrumb'
][
$key
][
'text'
]
=
t
(
'Edit'
)
.
' '
.
$node
->
type
->
entity
->
label
();
$variables
[
'breadcrumb'
][
$key
][
'url'
]
=
''
;
}
// Adjust breadcrumb for nodes.
if
(
$node
=
\Drupal
::
routeMatch
()
->
getParameter
(
'node'
))
{
if
(
$node
instanceof
NodeInterface
)
{
// Unset items, except home link.
foreach
(
$variables
[
'breadcrumb'
]
as
$key
=>
$item
)
{
if
(
$key
>
0
)
{
unset
(
$variables
[
'breadcrumb'
][
$key
]);
}
}
// Add bundle info.
$variables
[
'breadcrumb'
][]
=
[
'text'
=>
t
(
'Edit'
)
.
' '
.
$node
->
type
->
entity
->
label
(),
'url'
=>
''
,
];
}
}
// Adjust breadcrumb for other entities.
elseif
(
$entity
)
{
// Add bundle info.
$variables
[
'breadcrumb'
][]
=
[
'text'
=>
t
(
'Edit'
)
.
' '
.
$entity
->
getEntityType
()
->
getLabel
(),
'url'
=>
''
,
];
}
}
// Node add: Fix Drupal 9 issue.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment