Search code examples
menudrupal-7

How to make parent menu active when the child menu was active in menu block using drupal 7?


I have created menu and its child links like

About
  contact us
  portfolio
  our location

I have used menu block to display sub menu only when about in click and display sub menus in another layer.

Now my requirement is when i click on any sub menu in parent menu then the parent menu should be active. To achieve this task i searched a lot off and found menu position module for this purpose. I have configured and specify page path in Restricted to certain pages, but now it is now working. What i have mistake or any other solution for this problem. Please let me know the right solution.

enter image description here enter image description here

<?php
    $block = module_invoke('menu_block', 'block_view', '1');
    print render($block['content']);
?>

I am adding this code below the topbar menu. but inside the menubar wrapper.

enter image description here


Solution

  • Actually there is no requirement to use any module for this situation. What i have done to achieve it. I just modified template.php of zurb foundation theme. i have copied the code(foreach loop code) from here and added to the template.php file as mentioned in the page and added the css like below:

    #main-menu li.active-trail  a,
    #main-menu li a.active, #main-menu li a:hover {
      background:#fec325;
      /* IE6-9 */
    }
    

    and that's it. i have achieve what i want. I hope anybody who is looking same kind of problem can find this solution useful for this kind of requirement.