Add a custom menu in Drupal 6

Basic Menu

There are three default menus available in a fresh Drupal installation.

  • Primary links – Often used to present the main sections of the website, for example as tabs along the top
  • Secondary links – Often used for pages like legal notices and contact details along the bottom
  • Navigation – Often only visible for authenticated users, showing personalised links

These can be renamed, restructured and redesigned. For details on how to set up the basic menu structure of your Drupal website please see here: https://drupal.org/documentation/modules/menu

Custom Menu

In order to add a custom menu to your theme there are three steps to complete:

  • Create a new menu
  • Add the new menu to the theme’s template.php file
  • Call for the menu

All three steps are described in detail below.

Create a new menu:

Go to the administer page https://www.yoursite.com/admin and click on the menu link

Then click on the “Add menu” link

Give you new menu a machine-readable name, in my example it will be “custom”. You can choose your own. But remember the name for later. When you are finished, click save.

Now you can add some items to the list. If you don’t know how to do this, refer to the instructions here: https://drupal.org/documentation/modules/menu

Add the new menu to the theme’s template.php file
Find the template.php file within your theme folder (Themes are located in sites ‘/all/themes/’, in case there is no template file just create an empty file called template.php and place it in your themes root folder ‘sites/all/themes/yourtheme’).

Add the following lines below the last line in the document:

 

  • Replace “yourtheme” with the name of your theme (the name of your theme can be found here: https://www.yoursite.com/admin/build/themes).
  • Replace the two appearances of “custom” with the name of your menu

Call for the menu

Now, after we have created the theme in Drupal, and registered it in the theme, we have to let Drupal know where we want to show the menu on the website. This can be done by placing the following code snipped in a .tpl (example: node.tpl.php) file in your theme:

	

Now the menu shows up in the location you have chosen. If not, check if the names of your theme and your menu are correct (case sensitive). If it still doesn’t work, you may need to customise the code a little depending on your theme. See your themes documentation for more details or contact the theme developer. Or if you like, drop me a line below.

6 thoughts on “Add a custom menu in Drupal 6

Leave a Reply

Your email address will not be published. Required fields are marked *

x


Angebot anfordern

Ich melde mich innerhalb von 24 Stunden zurück.