Tuesday, March 19, 2013

Hiding the secondary menu on a single page in Drupal

If you want to hide the secondary menu on a single page in Drupal, this doesn't seem to be possible through the Administration web interface. You can disable all Secondary menus on your website, through the Appearance settings of your team (Appearance -> Settings -> name of your theme), but this is not what we are trying to achieve here.

You can disable the secondary menu on a single page however, by adding a few lines of code to your CSS files. Before you start editing your CSS files, you need to uniquely identify the page on which you want to hide the secondary menu. Drupal by default generates a unique ID for each page as a class ID of the body element in the format "page-<NAME>". You can lookup this value by using the Developer Tools of your browser and checking the class attribute of the body HTML element.



Then add the following lines of code to your CSS file:

.page-<NAME> #submenu{
 display:none;
}

The secondary menu section on a Drupal page is identified with the "submenu" id. The display:none property hides an element, and it will not take up any space. So this code snippet in your CSS file will avoid that the submenu is displayed on the page identified by string value after the "." class selector.

Author: Kristof Lievens

No comments:

Post a Comment