How to define a custom breadcrumb for a view?

Last modified: October 11, 2008 - 03:56

I needed to set a custom breadcrumb for every view I created.

I came up with the following code, put this in the argument handling code section of the view:

$breadcrumb[] = l('Home', null);
$breadcrumb[] .= l('News', 'news');
$breadcrumb[] .= l('Politics', 'politics');
drupal_set_breadcrumb($breadcrumb);

In this case, the breadcrumb will look like this:

Home -> News -> Politics

Maybe there's a way to customize this code to use a full vocabulary - term path.

Thanks to gbear for the idea.

Any better ideas are welcome...

Custom breadcrumbs for panels

doc2@drupalfr.org - October 12, 2008 - 16:25

For my panels (v.5.x-1.x), I simply put this code into the body of any custom-defined content of the panel and set this body's "Input format" to "PHP code". And it's done!

What is the code for Drupal

jmesam - December 3, 2008 - 01:54

What is the code for Drupal 6?

For drupal 6 go to the

lelizondob - December 3, 2008 - 05:48

For drupal 6 go to the original discussion http://drupal.org/node/215475

It's cool, but why doesn't

miles28 - December 19, 2008 - 12:30

It's cool, but why doesn't it print when browsing the site as user. I can only see these kind of breadcrumbs for views if I browse logged out.

I don't have this problem

lelizondob - December 19, 2008 - 18:06

I don't have this problem and without more info I don't know how to replicate it. Don't see a reason why this wouldn't work for logged users.

Luis

Views with Arguments...

pelicani - January 7, 2009 - 14:10

This solution does NOT address the breadcrumb problems when dealing with a view with arguments.
The view module will continue to append its own breadcrumb to this.
continuing to find a solutions...

peace,
michael

Web Developer : RockRiverStar.com : Philadelphia, PA

It seems to work for me.

adamo - February 18, 2009 - 19:31

It seems to work for me. Make sure your custom PHP pane appears after your view pane in your panel.

Put the code in the View Header

pianomansam - May 12, 2009 - 19:38

For this to work in Drupal 5.17, I had to put it in the header and set the Input Filter to PHP.

This seems to work alright

steveoliver - January 11, 2009 - 05:17

This seems to work alright for me.

--
Steve
Circatree

 
 

Drupal is a registered trademark of Dries Buytaert.