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

AttachmentSize
menu_block.module.patch2.5 KB

#1

JohnAlbin - January 2, 2009 - 11:11
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?

#2

JohnAlbin - January 2, 2009 - 11:35
Title:Menu Block tree not easily distinguishable in theme hooks» Menu Block tree not easy to recognize in theme hooks

#3

corhere - January 5, 2009 - 05:12

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

joachim - February 3, 2009 - 10:30

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!

 
 

Drupal is a registered trademark of Dries Buytaert.