function navigation_page_top
Implements hook_page_top().
File
-
core/
modules/ navigation/ navigation.module, line 44
Code
function navigation_page_top(array &$page_top) {
if (!\Drupal::currentUser()->hasPermission('access navigation')) {
return;
}
$navigation_renderer = \Drupal::service('navigation.renderer');
assert($navigation_renderer instanceof NavigationRenderer);
$navigation_renderer->removeToolbar($page_top);
if (\Drupal::routeMatch()->getRouteName() !== 'layout_builder.navigation.view') {
// Don't render the admin toolbar if in layout edit mode.
$navigation_renderer->buildNavigation($page_top);
$navigation_renderer->buildTopBar($page_top);
return;
}
// But if in layout mode, add an empty element to leave space. We need to use
// an empty .admin-toolbar element because the css uses the adjacent sibling
// selector. The actual rendering of the navigation blocks/layout occurs in
// the layout form.
$page_top['navigation'] = [
'#type' => 'html_tag',
'#tag' => 'aside',
'#attributes' => [
'class' => 'admin-toolbar',
],
];
$navigation_renderer->buildTopBar($page_top);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.