Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drupal Upstream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
ASC IRIS Web Services
Drupal Upstream
Commits
91915d25
Commit
91915d25
authored
6 years ago
by
Brian Canini
Browse files
Options
Downloads
Patches
Plain Diff
patch - menu_block: allowing 2nd level menu_block not limited to active parent
parent
faa08fe7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
composer.json
+2
-1
2 additions, 1 deletion
composer.json
vendor/composer/installed.json
+2
-1
2 additions, 1 deletion
vendor/composer/installed.json
web/modules/menu_block/src/Plugin/Block/MenuBlock.php
+25
-2
25 additions, 2 deletions
web/modules/menu_block/src/Plugin/Block/MenuBlock.php
with
29 additions
and
4 deletions
composer.json
+
2
−
1
View file @
91915d25
...
...
@@ -244,7 +244,8 @@
"2962965"
:
"https://www.drupal.org/files/issues/2018-09-01/block-permissions-2962965-4.patch"
},
"drupal/menu_block"
:
{
"2809699"
:
"https://www.drupal.org/files/issues/2018-10-26/menu_block-label_configuration-2809699-82.patch"
"2809699"
:
"https://www.drupal.org/files/issues/2018-10-26/menu_block-label_configuration-2809699-82.patch"
,
"2811337"
:
"https://www.drupal.org/files/issues/menu_block-2_level_menu_block_not_limited_to_active_parent-2811337-58.patch"
},
"drupal/entity_embed"
:
{
"2881745"
:
"https://www.drupal.org/files/issues/2018-12-04/2881745-22.patch"
...
...
This diff is collapsed.
Click to expand it.
vendor/composer/installed.json
+
2
−
1
View file @
91915d25
...
...
@@ -4636,7 +4636,8 @@
}
},
"patches_applied"
:
{
"2809699"
:
"https://www.drupal.org/files/issues/2018-10-26/menu_block-label_configuration-2809699-82.patch"
"2809699"
:
"https://www.drupal.org/files/issues/2018-10-26/menu_block-label_configuration-2809699-82.patch"
,
"2811337"
:
"https://www.drupal.org/files/issues/menu_block-2_level_menu_block_not_limited_to_active_parent-2811337-58.patch"
}
},
"installation-source"
:
"dist"
,
...
...
This diff is collapsed.
Click to expand it.
web/modules/menu_block/src/Plugin/Block/MenuBlock.php
+
25
−
2
View file @
91915d25
...
...
@@ -209,13 +209,36 @@ public function build() {
if
(
$depth
>
0
)
{
$parameters
->
setMaxDepth
(
min
(
$level
+
$depth
-
1
,
$this
->
menuTree
->
maxDepth
()));
}
// For menu blocks with start level greater than 1, only show menu items
// from the current active trail. Adjust the root according to the current
// position in the menu in order to determine if we can show the subtree.
// If we're using a fixed parent item, we'll skip this step.
$fixed_parent_menu_link_id
=
str_replace
(
$menu_name
.
':'
,
''
,
$parent
);
if
(
$level
>
1
&&
!
$fixed_parent_menu_link_id
)
{
if
(
count
(
$parameters
->
activeTrail
)
>=
$level
)
{
// Active trail array is child-first. Reverse it, and pull the new menu
// root based on the parent of the configured start level.
$menu_trail_ids
=
array_reverse
(
array_values
(
$parameters
->
activeTrail
));
$menu_root
=
$menu_trail_ids
[
$level
-
1
];
$parameters
->
setRoot
(
$menu_root
)
->
setMinDepth
(
1
);
if
(
$depth
>
0
)
{
$max_depth
=
min
(
$level
-
1
+
$depth
-
1
,
$this
->
menuTree
->
maxDepth
());
$parameters
->
setMaxDepth
(
$max_depth
);
}
}
else
{
return
array
();
}
}
// If expandedParents is empty, the whole menu tree is built.
if
(
$expand
)
{
$parameters
->
expandedParents
=
array
();
}
// When a fixed parent item is set, root the menu tree at the given ID.
if
(
$
menuLinkID
=
str_replace
(
$menu_name
.
':'
,
''
,
$parent
)
)
{
$parameters
->
setRoot
(
$menu
L
ink
ID
);
if
(
$
fixed_parent_menu_link_id
)
{
$parameters
->
setRoot
(
$
fixed_parent_
menu
_l
ink
_id
);
// If the starting level is 1, we always want the child links to appear,
// but the requested tree may be empty if the tree does not contain the
...
...
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