0

I am trying to create custom themes with bootstrap for Drupal 9. If I use the bootstrap5 theme as the base theme, I can access to the admin bar when viewing content. If I use any core themes as base theme, admin bar gone. I have looked up bootstrap5 template codes and functions, googled but couldn't find where to look apparently.

When using stable9 or classy as base theme and write all templates from scratch, how can I show the admin menu on non-admin pages?

1
  • It is not about blocks. I don't add any blocks when I try with bootstrap5 base, and admin bar appears.
    – loker
    Jun 11 at 11:41

1 Answer 1

0

Looking at toolbar.module, the toolbar is added to the page via hook_page_top() and the page_top area is output via html.html.twig.

The following snippet is taken from html.html.twig in core's stable9 theme:

...
<body{{ attributes }}>
  {#
    Keyboard navigation/accessibility link to main content section in
    page.html.twig.
  #}
  <a href="#main-content" class="visually-hidden focusable">
    {{ 'Skip to main content'|t }}
  </a>
  {# PAGE TOP IS OUTPUT HERE #}
  {{ page_top }}
  {{ page }}
  {{ page_bottom }}
  <js-bottom-placeholder token="{{ placeholder_token|raw }}">
</body>
...

Assuming you have the toolbar module enabled AND your theme (or base theme) is outputting page_top in its html.html.twig, then you should:

  1. Check the HTML source content for the toolbar div: per the twig above, it'll likely be directly below the #main-content link.
  2. Check for any errors in console: the contents of the toolbar are loaded via JS so it may be that toolbar is on the page, but a JS error is preventing it from rendering its contents.
  3. Check that the toolbar isn't simply being rendered underneath other content: i.e. a z-index issue.
  4. Check for any theme code that may be tampering with the contents of page_top: Make sure anything implementing hook_page_top() isn't overriding the contents of $page_top, specifically $page_top['toolbar'], make sure it's not doing something like $page_top = [etc...]
1
  • I have missed the page_top should call the toolbar as well. I was thinking that it was another block region. Thank you...
    – loker
    Jun 13 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.