Currently, menu_fields replaces the 'menu_link' theme function altogether. This is kind of extreme and will undo any styling that the theme was doing to the top-level <li ...></li> tag and the primary link.

For example, in a Bootstrap-based theme, it'll add a number of classes and data-* attributes to the <li ...></li> tag to turn the menu link into a dropdown, and add a 'caret' icon to the text of the primary link.

Because menu_fields replaces the 'menu_link' theme function completely, all these customizations are lost, AND the only way to add them back is to alter the theme registry, removing menu_fields_link() and redoing most of the code in that function. :-/

Proposal

Instead of replacing the 'menu_link' theme function entirely, use hook_preprocess_menu_link() to render the menu fields and use them to replace $vars['element']['#below']. This way the theme is still reponsible for rendering the menu link its normal way.

This has a couple of cool side benefits:

I'll post a proof-of-concept patch soon-ish...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dsnopek’s picture

Issue summary: View changes
dsnopek’s picture

Status: Active » Needs review
FileSize
2.33 KB

Patch is attached! Please let me know what you think. :-)

dsnopek’s picture

FileSize
2.39 KB
316 bytes

Here's a new version of this patch that also adds a class to menu links that have content added by menu_fields. This can be useful for styling mega menus different than normal dropdowns in your theme.

  • donutdan4114 committed a7dd14a on 7.x-1.x authored by dsnopek
    Issue #2460201 by dsnopek: Render fields into menu_links #below, rather...
donutdan4114’s picture

Status: Needs review » Fixed

Thanks!

dsnopek’s picture

Woohoo! Thanks for the quick commit! :-)

Status: Fixed » Closed (fixed)

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