Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Implement hook_navbar_view_alter to allow other modules to modify navbar links.
Comment | File | Size | Author |
---|---|---|---|
#1 | navbar-alter-navbar-links-1888322-1.patch | 585 bytes | shadcn |
Comments
Comment #1
shadcn CreditAttribution: shadcn commentedComment #2
redndahead CreditAttribution: redndahead commentedI'll second this request. I haven't tested the code, but by the looks of it it should work just fine.
Comment #3
markwk CreditAttribution: markwk commentedYes, I would like to see this feature added. I haven't reviewed or even checked this code but functionally we should add this so other modules can modify the menu items some.
In my use case, I'd like to take my Drupal 7 contrib module for Joyride tours to function in a similar way to what is being developed for core in Drupal 8: #1809352: Write tour.module and add it to core
Comment #4
markwk CreditAttribution: markwk commentedOk. Here is my hackish workaround to get it to add joyride tour link: https://github.com/markwk/tour_navbar.
Comment #5
jessebeach CreditAttribution: jessebeach commentedThe menu links should really be altered through the administration UI. This module is just pulling in the administration menu.
What else would you want to do to the links that a hook would be needed?
Comment #6
shadcn CreditAttribution: shadcn commentedMy use case was: using a different menu (not administration menu) as the navbar.
Comment #7
markwk CreditAttribution: markwk commentedI'd like to be able to have my module create a menu item in the top. In my specific use case, it would be a "start tour" link like you see in Drupal 8. I'm guessing other modules might was to add different stuff. I don't see this as needing a full UI for adding links.
Comment #8
jessebeach CreditAttribution: jessebeach commentedmarkwk, ah, I understand! We're working on those two features in D8.
#1939884: Make the administration menu in the toolbar plugabble: don't hardcode to the 'admin' menu
#1894964: Make the Toolbar PHP and JavaScript API more flexible so that it enables contrib to leverage it
For D7, though, much of that easy click-and-configure type interaction might not be possible or backported because we'll be leveraging systems in D8 that just don't exist in D7. I would be open to folks proposing patches to this module to recreate that behavior in a D7 way.
Otherwise, Navbar provides a
hook_navbar
hook that provides a means to place tabs in the toolbar and ahook_navbar_alter
hook to change existing toolbar items before rendering.Comment #9
jessebeach CreditAttribution: jessebeach commentedAll of the use cases in this issue are addressable through existing functionality.