Managing Breadcrumb Navigation in Drupal
The stock breadcrumb functionality in Drupal leaves something to be desired. It is often times too simple and does not provide intuitive breadcrumbing. Fortunately there are a number of ways to get around the limitations.
The MOST extensible method would be using the theme_breadcrumb hook. It has limitless possibilities. The trade off is it can introduce limitless complexity. If your site needs some heavy duty bread crumbs, by all means create a template hook.
I needed a quick and easy method of breadcrumbing. I achieved this by using the custom breadcrumbs module and a sprinkingling of php code. Fortunately my needs were relativly simple.
I have a view that contains a listing of a particular node type. One instance is Press Releases. Each list item links to a node. The Custom Breadcrumbs module only supports creating breadcrumbs for node pages, it does not currenlty support views. This makes creating the breadcrumbs a 2 step process.
Step 1. - Create breadcrumb rule using custom breadcrumbs.
Navigate to admin/build/custom_breadcrumbs.
Create a rule for your node type.
For Title use:
Node Name [title]
For Paths use:
node-type node/[nid]
Save it and navigate to a node detail page of the selected node type.
Next you'll need to create the breadcrumb for the node view.
Navigate to the edit screen of the view.
Under Page -> Header textfield you will be using the drupal_add_breadcrumb hook.
$links = array(l(t('home'), ''), l(t('Node Type'), 'node-list-url')); drupal_set_breadcrumb($links);
Be sure to select PHP as your input format.
The above is a real basic example and assumes you are using a "page" view. It should provide the basic details.
- Login to post comments