7

I know that in drupal 6 exist: theme_menu_item, but in drupal 7 there is not. Is there any replacements so that I modify the output for main system menu ?

Actually I want to do a kind of filter of the menu items depending some criteria, which I will set in the function.

  • Could you please rephrase your question to 'What is the equivalent of theme_menu_item in Drupal 7'? – Chris Cohen Mar 15 '11 at 16:08
5

Looking at the function that called the theme function theme_menu_item() (menu_tree_output()), and comparing it with the Drupal 7 version of the same function, I can say that the equivalent of theme_menu_item() is theme_menu_link().

| improve this answer | |
  • Thanks, I have put function mytheme_menu_link(array $variables) in template.php file from my theme, but it has no effect to menu. I have checked with debugger and the function is not processed by drupal, just as he doesn't recognize this hook... – Ek Kosmos Mar 15 '11 at 13:57
  • @Ek Kosmos: theme_menu_link() is not a hook, but a theme function. Theme implementation needs to be registered using hook_theme(), as reported in Default theme implementations. – kiamlaluno Mar 15 '11 at 14:08
  • "Each module should provide a default implementation for theme_hooks that it registers. This implementation may be either a function or a template; if it is a function it must be specified via hook_theme(). By convention, default implementations of theme hooks are named theme_HOOK. Default template implementations are stored in the module directory." – kiamlaluno Mar 15 '11 at 14:08
4

The theme_menu_item() function has been replaced by theme_menu_link(). For details on this change, and all other changes made to the theme layer between Drupal 6 and 7, see the Converting 6.x themes to 7.x page. There is also a corresponding module conversion page.

| improve this answer | |

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.