Menu Block tree not easy to recognize in theme hooks
corhere - December 22, 2008 - 08:31
| Project: | Menu block |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Description
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.
| Attachment | Size |
|---|---|
| menu_block.module.patch | 2.5 KB |

#1
Giving 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?
#2
#3
I 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?
#4
Subscribing.
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!