It is impossible to theme menus differently. You need developer skills and a fair amount of knowledge about the menu system to alter the output of a certain menu.

Attached patch fixes this bug by leveraging the theme system's capability of theme function suggestions.

No API change, no functional change, just an additional theme suggestion.

#14 KBeffulgentsia
Passed on all environments.
[ View ]
#2 KBsun
Passed on all environments.
[ View ] KBsun
Passed on all environments.
[ View ]


Just found #588148: theme_links() is not really themeable, which tries to do the same to theme_links.

new1.15 KB
Passed on all environments.
[ View ]

Updated for the more failsafe naming standard mentioned in #588148: theme_links() is not really themeable

In addition to your proposal,

Wouldn't it be nice to do drupal_alter('menu_tree_output', $output, $menu_name) on the result of menu_tree_output()?


Overriding theme_menu_link() and theme_menu_tree() is nice, but inside these two functions you still don't know about the surrounding items. E.g., inside theme_menu_link() you don't know your position so you can't add 'odd' / 'even' classes.

Anything left here?

sun requested that failed test be re-tested.

So is this RTBC?

Status:Needs review» Reviewed & tested by the community

Looks great. We're a bit too late for #408150: Add "Welcome, $username" to user links but still nice to have

Status:Reviewed & tested by the community» Needs review

Re-test of from comment #2 was requested by webchick.

Status:Needs review» Reviewed & tested by the community

as per #9

Status:Reviewed & tested by the community» Needs work

I committed #653622: Make the '__' pattern for theme suggestions easier to use. This one will need a re-roll.

Status:Needs work» Reviewed & tested by the community
new1.11 KB
Passed on all environments.
[ View ]


Status:Reviewed & tested by the community» Needs work
Issue tags:+Needs Documentation

In retrospect, it's probably a bit late for all three of these patches, but since I committed the first in the series, I guess we might as well finish the set. At least it doesn't break anything. :) (famous last words)

Committed to HEAD. Needs documenting in the theme upgrade guide.

Assigned:sun» Unassigned

I started to document this, but stopped, realizing that a bug that was fixed in D6, but not yet in D7 is preventing this particular use-case from working. I think it makes sense to have #241570: Theme preprocess functions do not get retained when using patterns get resolved before telling theme developers about this cool new toy that doesn't work yet.

Status:Needs work» Postponed

Changing status to reflect #16.

#338027: Better menu template suggestion has been marked as duplicate

Status:Postponed» Fixed

Status:Fixed» Closed (fixed)

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

it doesn't work when the menu name is longer than one word.

[menu_name] => secondary-menu

you can't have dashes in php function names

themeName_menu_link__management -works

but it never pics up the secondary menu

intel_agate_menu_link__secondary_menu it's trying to match the - and not an underscore.

I would like to confirm #21.
As PHP does not allow dashes in function signatures using the proposed naming method does not work for newly created menus as new menunames are always prepended with menu.

No time to look into the theme suggestions so no further contributions there.