A hook_menu() item can take an options array. This is used for rendering the menu item as a link, just as it is in the l() function. Patch to follow.

Comments

darren oh’s picture

Status: Active » Needs review
StatusFileSize
new893 bytes
jhodgdon’s picture

Status: Needs review » Needs work

Hmmm. Is that true? Does it apply to Drupal 6 as well? And under what circumstances are the options used -- only if it is displayed in your Primary Links or another menu, or is it also used if you are on for instance the Configuration page that displays all the admin/configure page links?

If it is true, I would like to see this reworded slightly to say something like "An array of options to be passed to l() when generating the menu link", and then describe when exactly it's used.

jhodgdon’s picture

I did some investigating.

It seems that this applies to anything that is marked as MENU_VISIBLE_IN_BREADCRUMB, and that these options are merged with some defaults and saved in the menu links table. See http://api.drupal.org/api/constant/MENU_VISIBLE_IN_BREADCRUMB/7 -- which includes MENU_DEFAULT_LOCAL_TASK, MENU_LOCAL_ACTION, MENU_LOCAL_TASK, MENU_NORMAL_ITEM, and MENU_SUGGESTED_ITEM.

But I'm not sure when exactly these are used in rendering.

darren oh’s picture

Assigned: darren oh » Unassigned

Rendering happens in theme_menu_link() in Drupal 7 and in theme_menu_item_link() in Drupal 6.

jhodgdon’s picture

I think it's also happening in breadcrumb theming.

jhodgdon’s picture

OK. Then we just need a minor rewording as I suggested in #2... How about:

An array of options to be passed to l() when generating a link from this menu item.

darren oh’s picture

Status: Needs work » Needs review
StatusFileSize
new874 bytes

Sounds good to me.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, thanks!

If committed, we should also port this to D6.

jhodgdon’s picture

#8: system.api_.php-888747-8.patch queued for re-testing.

dries’s picture

Is theme_menu_link() even used?

jhodgdon’s picture

Yes, theme_menu_link() is being used, at least by default.

Where/how: http://api.drupal.org/api/function/menu_tree_output/7 puts #theme = 'menu_link__' . $data['link']['menu_name'] on each menu item it sets up for rendering, which will default back to looking for theme('menu_link') if the specific theme function doesn't exist, according to http://api.drupal.org/api/function/theme/7 (and you can see this happening in the code too).

That function menu_tree_output() is called from several functions that build menus for output, such as menu_tree() (which is used by several modules to render menus) and some book module functions.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Looks like I committed this patch already along with another patch. Sorry for omitting the proper credit! :/

Status: Fixed » Closed (fixed)

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