Saturday, May 28, 2011

Menus in Drupal

I could not decide where to start on my local Drupal site.  While playing Street Fighter 2, I found a need for a quick way to reference the keypad combinations for the moves of each fighter.  Anything I found text files on the Internet, but navigating through these text files proved to be quite difficult.  So I decided to start with this quick reference for Street Fighter 2 moves.

I wanted a menu structure similar to the following:
--Street Fighter 2

I started by creating a page for each fighter, but none of my new pages showed up in a menu.  I could not understand what I had to change to make my fighters show up on a menu.  I eventually found that I had to create my menu infrastructure as Primary Links.  The fighters' pages already existed, but I need a page for the Games, Street Fighter 2, and Fighters menus. 

After I created the additional pages I needed, I could create the desired menu infrastructure.  I clicked on Administer, Site Building, Menus, and Primary links.  See the screen shot below for a visual path.

You can create the menu infrastructure by clicking on Add item.  On that page, enter the path for the page (node) to link to and the menu item title.  Next be sure to check the Enabled check box.  Finally, the correct parent item should be selected in the Parent item.  If I wanted to add a main menu item (i.e. Home or Games), the parent item would be <Primary links>.  I could then add Street Fighter II by adding a new menu item and selecting --Games as the Parent item.  Next I could add Fighters underneath Street Fighter II and then all of my fighters (Ryu, Ken, etc.)  

You can also specify the Parent item while editing the page.

I also wanted to be able to see my entire menu infrastructure on the left side of the browser.  This can be accomplished by setting up a Block.  Blocks can be accessed by clicking on Administer, Site building, and Blocks.  I dragged the Primary links menu up from the Disabled region to the Left sidebar region.  After clicking Save blocks, the menu showed up on the left side of the browser. 

I noticed that Drupal displayed my menu infrastructure in the top right corner of my site.  

During my research of menus in Drupal, I stumbled across a way for sub-menus to be displayed and change with the currently selected menu.  If you navigate back to the Menus administration page (see the screen shot below), you can modify the settings by clicking on the Settings link.

If you change the setting for Source for the secondary links from Secondary links to Primary links, Drupal will display the appropriate sub-menu in the upper-right corner.  Keep in mind that the theme determines where these links will appear.  See below for the result after changing this setting.

That sums up my experience with menus.  I also worked a bit with the Submenu Tree module, but I will save that for another post.

Thanks for reading.

No comments:

Post a Comment