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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JohnAlbin’s picture

Title: Menu Block tree not customizeable by theme hooks (with patch) » Menu Block tree not easily distinguishable in theme hooks
Version: 6.x-2.2 » 6.x-2.x-dev

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?

JohnAlbin’s picture

Title: Menu Block tree not easily distinguishable in theme hooks » Menu Block tree not easy to recognize in theme hooks
corhere’s picture

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?

joachim’s picture

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!

JohnAlbin’s picture

Status: Needs work » Needs review
FileSize
8.4 KB

corhere, 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.

JohnAlbin’s picture

Title: Menu Block tree not easy to recognize in theme hooks » Add theme hook suggestions for all theme functions called by menu_block

Updated title.

JohnAlbin’s picture

Status: Needs review » Fixed

Committed!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.