Drupal creating subnavigation menu and setting parent link active

Have you ever thought of creating a sub navigation menu in drupal and setting the parent section tab active in main navigation. Really it was a tough thing for me. Now I know it and I will explain you how.

To create a sub navigation you must have the main navigation set up either with primary links or secondary links.

To create the main navigation in drupal.
1. Create content node. While creating the content page, under menu settings select the parent item as primary links or secondary links.
2. Customize css of primary links or secondary links accordingly.
3. In css, use active and active-trail classes in primary links or secondary links to set the active state of any link.

To create sub navigation for any section in main navigation follow the below steps. (I am assuming primary links is set up as the main navigation. Any of secondary links or primary links can be set up as main navigation)
1. Always create the content first. Create content >
2. While creating content, under the menu settings, select one of the items in primary links as the parent item.
3. Repeat the above 2 steps for all the sub navigation pages under a section in main navigation.
4. Go to administer>menus> and add a menu.
5. Add items to the created menu.
6. Go to administer>blocks. Menu items will be shown in the blocks. Blocks can be assigned to any predefined regions.
7. Configure the blocks to display the block only in certain pages.

Then you should be able to see the sub navigation in the desired pages with selected section active in main navigation.


No Comments so far

Leave a comment

(required)

(required)




AUTHOR

profileWeb Developer working in advertising agency.

Recent tweets

The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.