By mtropea55 on
I am trying to set up a custom menu in my theme, but when the output is displayed the children do not show up. The primary links show up, but if I set any of the links to have children, they do not show. I've tried using the menu_tree function but I couldn't figure out how to custom theme that either. Any help would be much appreciated. The code I am using is:
<div id="menu-container">
<?php if (is_array($primary_links)) : ?>
<ul id="menu">
<?php foreach ($primary_links as $link): ?>
<li><?php $href = $link['href'] == "<front>" ? base_path() : base_path() . drupal_get_path_alias($link['href']);
print "<a href='" . $href . "'>" . $link['title'] . "</a>"; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>The output I'm looking for should look like:
<div id="menu-container">
<ul id="menu">
<li><a href="/home">HOME</a></li>
<li><a href="/events">EVENTS</a>
<ul>
<li><a href="/events">Upcoming Events</a></li>
<li><a href="/previous-events">Previous Events</a></li>
</ul>
</li>
<li><a href="/image">PICTURES</a></li>
<li><a href="/contact">CONTACT</a></li>
</ul>
</div>
Comments
You can use menu_tree
You can use menu_tree function:
For alternative solution, you can use menu block module:
http://drupal.org/project/menu_block
--
Suryanto Rachmat
Thanks suryanto, but the
Thanks suryanto, but the problem I had was I couldn't stylize the
<ul>and<li>tags. Drupal kept adding it's own classes. I think there is a function override I could put into the templates.php but I couldn't find anything.Here's the code I use to make
Here's the code I use to make sure the children menu items show up:
You can use theme_menu_tree, theme_menu_item, and theme_menu_item_link to override the respective outputs. Hope that helps!
Thanks chronnus. Your
Thanks chronnus. Your function worked great.