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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

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

sun’s picture

FileSize
1.15 KB

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

mooffie’s picture

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()?

Rationale:

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.

sun’s picture

sun’s picture

Anything left here?

sun requested that failed test be re-tested.

catch’s picture

sun’s picture

So is this RTBC?

catch’s picture

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

effulgentsia’s picture

Status: Reviewed & tested by the community » Needs review

Re-test of drupal.menu-theme.2.patch from comment #2 was requested by webchick.

effulgentsia’s picture

Status: Needs review » Reviewed & tested by the community

as per #9

webchick’s picture

Status: Reviewed & tested by the community » Needs work
effulgentsia’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.11 KB

re-rolled.

webchick’s picture

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.

effulgentsia’s picture

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.

effulgentsia’s picture

Status: Needs work » Postponed

Changing status to reflect #16.

hass’s picture

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

effulgentsia’s picture

Status: Postponed » Fixed

Status: Fixed » Closed (fixed)

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

frogrod’s picture

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.

jitse’s picture

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.

Elijah Lynn’s picture