(Tutorial) Theming Drupal primary links with child sub-menus
Theming Drupal primary links with child sub-menus
Using 'Primary links' for your Drupal site's main navigation menu is a great idea. However, most themes by default display primary links in such a way that if the menu has sub-child menus, they will not be displayed. Fortunately, the solution is much easier that you'd think.
First off, the way that most themes generate primary links is like so:
theme('links',
$primary_links);
As mentioned, this will only output the top-level menu items, like so:
<ul> <li>Menu Item 1</li> <li>Menu Item 2</li> <li>Menu Item 3</li> </ul>
That's not very useful for sites with a robust navigation tree.
To get around this, the simplest way is to remove the original theme() function outputing the primary links, and create a new region in your template where you'd like your navigation menu to show up. Then, you can assign the 'Primary links' block to that region, and the entire menu tree will be displayed there.
To create a region in Drupal 5:
You'll need to modify your theme's template.php file. If it doesn't yet have one, create it, and enter the following:
function name_of_theme_regions() { return array( 'name_of_new_region' => t('name of new region'), ); }
Courtesy : http://nicksergeant.com
- guru's blog
- Login to post comments
![Drupal-6-Book-[Building Powerful and Robust Websites with Drupal 6].jpg](http://www.drupalranch.com/images/Drupal-6-Book-[Building%20Powerful%20and%20Robust%20Websites%20with%20Drupal%206].jpg)