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.
I was unable to customize the tree generated by Menu Block without also messing up all the other menus on the site. I modified the module so that there are now three theme hooks that can be used to customize only Menu Block menus (menu_block_item, menu_block_item_link and menu_block_tree). The value of delta is also passed to these hooks.
The code is undocumented, as I am not very good at writing documentation.
The patch is for the 6.x-2.2 version.
Comment | File | Size | Author |
---|---|---|---|
#5 | theme-hook-suggestions-350029-5.patch | 8.4 KB | JohnAlbin |
menu_block.module.patch | 2.5 KB | corhere | |
Comments
Comment #1
JohnAlbinGiving menu_block its own theme hooks breaks integration with other contrib modules. For example, DHTML Menus acts on theme('menu_link').
So switching the theme hooks is a no-go.
We can, however, pass additional data to the theme hooks without switching which theme hooks are used.
BTW, what were you trying to do?
Comment #2
JohnAlbinComment #3
corhere CreditAttribution: corhere commentedI was trying to make the menu links for a specific menu appear as images.
I don't think that my patch would break other modules, as the new theme hooks in turn call the corresponding menu hooks by default. As theme() accepts an array of hooks, calls to theme('menu_link') could instead become theme(array('menu_block_link', 'menu_link')), which AFAIK would not break other modules either. I am new to Drupal, so I could be completely off about this.
Would it be possible to have, as well as the delta, an arbitrary identifier passed to the theme hooks? Maybe a string that can be specified in the individual menu's configuration?
Comment #4
joachim CreditAttribution: joachim commentedSubscribing.
I had a designer who wanted to add a span to menu items in a *particular* menu block, and I couldn't find a way to do it.
Additional data passed to the theme functions would be great -- such as menu block ID.
BTW, this module is ace :D Thanks for your work on it JohnAlbin!
Comment #5
JohnAlbincorhere, yeah, I've been thinking about passing an array of hooks as the first param for several months now. I think that's the way to go.
Here's the patch I'm working on. 95% complete, I think. I'll commit in the next couple days.
Comment #6
JohnAlbinUpdated title.
Comment #7
JohnAlbinCommitted!