1

So I want menus to output in a custom way. I would not output the following HTML.

<ul attributes>
    <li attributes>
       <a href="foo">foo</a>
    </li>
    <li attributes>
       <a href="bar">bar</a>
    </li>
 </ul>

I would replace it with the following one.

<nav attributes>
   <a attributes href="foo">foo</a>
   <a attributes href="bar">bar</a>
</nav>

So I put in the template.php file the following function (my theme is called mFAC).

function mFAC_links($variables) {
    // custom stuff
}

I am starting with a light alteration, but nothing seems to have any effect. I cleared the cache.

Is there anything I am missing?

  • Did you rebuild the theme registry == clear caches ? And BTW, your function should return $output. Does it ? – Countzero Apr 19 '12 at 6:00
  • So far I have just copied and pasted the function from theme.inc with only a slight variation to test that its having an effect. I cleared the caches and it does return $output – Fresheyeball Apr 19 '12 at 6:07
  • How are your links output in your tpl.php ? – Countzero Apr 19 '12 at 6:30
1

You can use YOUR_THEME_menu_tree() for this. You can target it to a specific menu using YOUR_THEME_menu_tree__MENU_NAME(). Make sure you return the variable after alterations. Refer this for more details.

1

You can override the menu wrapper in this manner:

function YOURTHEME_menu_tree__MENU_NAME($variables) {
  return '<nav class="menu'.$variables['delta'].'">' . $variables['tree'] . '</nav>';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.