function NavigationMenuLinkTreeManipulators::addSecondLevelOverviewLinks
Adds an "overview" child link to second level menu links with children.
In the navigation menu, a second-level menu item is a link if it does not have children, but if it does, it instead becomes a button that opens its child menu. To provide a way to access the page a second-level menu item links to, add an "overview" link that links to the page as a child (third-level) menu item.
Parameters
\Drupal\Core\Menu\MenuLinkTreeElement[] $tree: The menu link tree to manipulate.
Return value
\Drupal\Core\Menu\MenuLinkTreeElement[] The manipulated menu link tree.
File
-
core/
modules/ navigation/ src/ Menu/ NavigationMenuLinkTreeManipulators.php, line 46
Class
- NavigationMenuLinkTreeManipulators
- Provides a menu link tree manipulator for the navigation menu block.
Namespace
Drupal\navigation\MenuCode
public function addSecondLevelOverviewLinks(array $tree) : array {
if (!$tree) {
return [];
}
foreach ($tree as $item) {
if (!$this->isEnabledAndAccessible($item)) {
continue;
}
foreach ($item->subtree as $sub_item) {
if ($this->shouldAddOverviewLink($sub_item)) {
$this->addOverviewLink($sub_item);
}
}
}
return $tree;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.