<?php if (isset($custom_links)) { ?>
<div id="secondaryNav"><?php print theme('links', $custom_links) ?></div>
<?php } ?> 

I've create a custom menu (machine name: menu-secondary-menu). And I want to display it in page.tpl. My condition is to show this this menu only if it has links added. I searched and found the above code. Please help me in customizing to my need.


1 Answer 1

// Enter the machine name of the menu you want to show.
$menu_name = 'main-menu';
// Check if there are any menu items in it.
if (count(menu_navigation_links($menu_name))):
<div id="secondaryNav">
  <?php print theme('links', array('links' => menu_navigation_links($menu_name), 'attributes' => array('id' => $menu_name, 'class'=> array('links', 'inline')))); ?>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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