I'm using taxonomy menu and nice menus to generate the page main menu. Not every term has related nodes, but the customer wants them all to be in the menu, but the "empty" terms not clickable. And when he creates nodes related to these terms, the terms should turn in to links. Can I achieve that with hook_page_alter? Or is there a better hook to use. I first tried hook_url_outbound_alter, and I was able to rewrite the path, but it's still a link, and I want to avoid that. I know how to use rendered arrays, but this one is a bit tricky for me.


I would do that using hook_menu_link_alter() and Special Menu Items module, which provides special menu items like <nolink > and <separator>.

  • Thanks, but saw your answer after finding the solution with hook_nice_menus_build($variables) and javascript. – krabbe Jul 2 '14 at 10:02

I found the right hook in nice menus module. With hook_nice_menus_build($variables) I'm able to check every menu item about referenced nodes. Then I can add a class like 'js-no-nodes' and use javascript/jquery to replace the with .

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.