Skip to content Skip to navigation

Breadcrumbs for Views pages

Posted by: 
Topics: 
ZC: With permission from the author, Daniel Hanold, I am pasting in his documentation (below) of how to use Views Arguments to create customized breadcrumbs for Views pages. As of the time of this writing the Custom Breadcrumbs module does not seem to handle Views breadcrumbs is a thoroughly stable fashion, though it appears that it will, so this information may soon be obsolete. Nevertheless, I think the more we can do with Views and other near-core modules, and resort to contrib less, the better. It's a solid piece of documentation. Thanks Danny!
source: http://www.danielhanold.com/story/views-breadcrumbs-using-arguments

For most of my clients, I need to create Breadcrumbs. Seemingly easily, breadbrumbs is an area that is a bit more involved than most features in Drupal. There's a great module out there called custom_breadcrumbs. The module works great for the display of breadcrumbs on all node pages, but doesn't (yet) work with views.

After doing some research about a solution for view pages, here's my favorite pick: Views Arguments.

For a simple overview page (that uses views), add a "Global: Null" Argument. Within that argument, select "Provide default argument" and select "PHP Code". In here, you can use the drupal_set_breadcrumb function. That function accepts an array of link titles and paths. Here's an example:

$breadcrumb[] = l('Home', null);
$breadcrumb[] .= l('Is The Box Butler For Me?', 'use-cases');
drupal_set_breadcrumb($breadcrumb);

To make this work, it's important to select "Display All Values" for "Action to take if argument does not validate", otherwise the view gets messed up.

To be on the safe side, I've attached a screenshot of the arguments code for this (live) example: http://theboxbutler.com/use-cases.