Choices in Navigation - An Overview

The Drupal framework provides a number of options for implementing navigation. This overview provides a brief description of the navigation choices with associated pros and cons. It is aimed at new Drupal implementors.

The following five navigation methods are reviewed:

  • Primary/Secondary Navigation
  • The Menu Module (part of Drupal base installation, called core)
  • The Book Module
  • Taxonomy
  • Hard-Coded HTML Block

Arguably there is a sixth method: The Blended Approach. It isn't uncommon to combine two or more of these methods. For example, the Drupal.org sites uses a combination of the Primary/Secondary navigation with the Book Module.

Selecting a navigation system does not lock you into that system. Drupal allows multiple, simultaneous navigation systems which can be selectively presented to different users. If you find your site changes over time you can adapt your navigation accordingly.

The Role of Themes

Drupal separates presentation from data. The navigation methods provide the data while the presentation is specified within the theme template. For example, CSS styling for mouse roll-over effects is a template issue. JavaScript usually falls into this category too, though in some cases it may be appropriate to enter it via the navigation module's administration menu. This separation allows the navigation menu look to change with the theme.

Conventions

When a module is said to be part of core, it is included in the base Drupal installation and need only be enabled from the modules menu in administer. When a module is said to be a contributed module it must be downloaded, installed and enabled after the base Drupal installation.

A Drupal Block is a specific feature and not a general term. Information on the Drupal Block can be found in Block: controlling content in the sidebars.

Primary/Secondary Navigation

Primary/Secondary navigation is a site navigation feature Drupal makes available to template designers. It is administered in the administer >> themes menu. By convention it's placed at the top of the page to provide a location for horizontal navigation elements. In reality it could be placed anywhere the theme designer wishes. It is the only way to add horizontal navigation without directly embedding it in the template.

The method for entering menu links is not consistent among templates or Drupal versions. In some cases a text area is provided in the template to enter HTML. In other cases fields are given for menu text and link targets. Some templates provide the CSS to create a tabbed look if you use <ul>/<li> markup to create your navigation structure.

Breadcrumbs are an issue with this module. When you click on a link and are taken to a content page the breadcrumb will revert to simply "Home".

More Information:

Pros

  • Provides horizontal navigation without custom coding the template
  • Depending on template, allows the insertion of JavaScript

Cons

  • Depending on the template, may have to hand code the HTML
  • Breadcrumbs don't work

Menu Module

Menu is a core module for creating and managing menus in Drupal Blocks. A full description can be found in the handbook module description

Menu Blocks can created as required. The Menu Blocks can be displayed based on page name and access descriptors. Multi-level menus that stay expanded or expand when accessed are possible.

Menus were originally created to reference Drupal pages only. Some versions of Drupal allow references to external websites, but you must be careful if you use this. It isn't supported in all versions and an upgrade could break it. It also means you can't make a "Home" reference using "/" as a link. There is no option to create a divider or textual labels to allow link grouping or titles.

In Drupal 4.6 a companion module named Menu on-the-fly can be used to simplify work flow. The ability to add a menu entry for a content node is placed on the content edit/submit form. This feature is built into Drupal 4.7.

Breadcrumbs do work down to the content level. They will properly reflect the menu hierarchy, but when the final content page is selected the breadcrumb will revert to "Home".

More Information:

Pros:

  • Easy updating via administer >> menus, no HTML coding required
  • Can specify which pages the menus appear on
  • Simplified work flow with Menu on-the-fly

Cons:

  • Hit and miss support for referencing external websites or "/"
  • Can't create labels or dividers
  • Breadcrumbs don't work to content level

Book Module

The Book Module is part of core and is slightly misnamed. It's really a hierarchical organization module, making it an option for site navigation. The Book module handbook page describes the module in the context of a book, but think site navigation when you read it!

When Book pages are created they are placed in a page hierarchy and receive automatic menu entries as well as other navigation elements. The page placement options are integrated into the content creation screen simplifying work flow. Book pages are standard Drupal nodes and can contain PHP.

The Book module has specific behaviours. Child pages are given navigation links from the parent page and other navigation elements such as next page and previous page are added. These behaviours either save a lot of work or render this option useless.

The page module is one of the few choices where breadcrumbs work correctly to the lowest page level.

More Information:

Pros:

  • Best option for providing working bookmarks
  • Navigation and content creation work hand-in-hand
  • Automatically creates next, previous, and up links

Cons:

  • Everything must fall within the book hierarchy or breadcrumbs break
  • Has specific behaviours which are not trivial to change

Taxonomy

The Taxonomy module doesn't do navigation, it allows you categorize your content so it can then be referenced by a navigation system. It is part of the Drupal core. In combination with other modules or PHP code you can create a menu system and automatic page placement simply by maintaining the content taxonomy.

The simplest method to provide navigation based on taxonomy is the Taxonomy Menu module. Taxonomy Menu is a contributed module and must be installed. It allows you to tap into the taxonomy structure for navigation. There are a plethora of other modules that leverage taxonomy, making it a very powerful way to organize your site.

If you're considering taxonomy based navigation system because of the suite of available support modules you should plan time to learn how these modules interact with each other. Taxonomy is indispensable for particular site architectures but overkill for smaller sites.

More Information:

Pros:

  • Particularly useful for sites with a large amount of content
  • Simplifies content management with automatic page placement.
  • Breadcrumbs work correctly with some implementations

Cons:

  • Much of the benefit of taxonomy comes with the other support modules, adding complexity
  • Overkill for small sites or relatively static sites

Hard Coded Block

If none of the previous navigation options meet your requirements you can create your own menu. For some types of JavaScript menu systems this is your only option. It is also your only option if your menu includes unlinked labels, dividers, or some types of HTML elements. Creating your own menu involves creating a Block and inserting the navigation HTML into the block.

You may be able to leverage some of the other menu types by calling the menu creation code with a PHP code snippet. This blended approach allows the leveraging of other Drupal modules.

Breadcrumbs will not work with this type of menu unless you are building on a module that manages breadcrumbs.

More Information:

Pros:

  • Extremely flexible
  • Can leverage other menu options with PHP
  • Only way to use unlinked labels and HTML elements in your menu

Cons:

  • HTML coding required to update the menu (highly manual)
  • Breadcrumbs don't work
  • Sophisticated navigation systems could require extensive coding or large amounts of manual labor.
 
 

Drupal is a registered trademark of Dries Buytaert.