Hide 'Home' link only on a breadcrumb

newdru - December 14, 2006 - 00:50

i tried to search on this but i couldn't really find what i'm looking for..

Lets say i have "section" page.. Let's call it "About Us"

When you click on that page.. i think it looks kind of dumb to have a breadcrumb that simply says:

Home

Now if you click on a page/node underneath "About Us", lets say "History", the breadcrumb now looks like:

Home > About Us

That's Looks better to me and makes more sense... (although i probably wouldn't mind getting rid of the Home here as well)..

Is there anyway to either:

1) globally remove 'Home" from ALL breadcrumbs
2) specifically remove 'Home' on breadcrumbs of certain pages

And as a side question:

3) Is there any way to include the current page/node being viewed as the last "crumb" in the breadcrumb traill?

I'm no expert on breadcrumbs but it kind of makes sense to me to do it this way.

FWIW.. i'm using category module and category menu. This may have an effect on my breadcrumbs are being displayed and or how they can be configured or themed

thanks in advance

look into the

VM - December 14, 2006 - 01:14

look into the advanced_menu.module which allows you to extend the breadcrumbs to be this way Home > About Us

to remove home from the breadcrumb trail may take some theme override.

Removing the breadcrumb on the home page

middguy - April 23, 2007 - 22:51

Hi there-

Though I can't help you get rid of home on all the pages, I can at least take it off the main page for you.

Go to your page.tpl.php file, and find the line:

<?php if ($breadcrumb): print $breadcrumb ?><?php endif; ?>

Edit this line to instead be:

<?php if ($breadcrumb && $title != "What you called your home page"): print $breadcrumb ?><?php endif; ?>

Hope that helps.

Try this on for size (Drupal 5.1)

skiquel - January 27, 2008 - 03:27

Edit: You can check out my article at: http://sensiblysecular.com/drupal/hiding_home_link_in_breadcrumb/

If your using PHPTemplate, here is some stuff you can try...

A crack at the breadcrumbs, in-template statement

Inside: page.tpl.php in your theme folder

Find (if exists):

<?php
    
if (isset($breadcrumb)) {
           
// delete this whole if structure, including its inner statements.
       
}   
?>

or Find:
<?php
  
print $breadcrumb
?>

Replace with:

<?php
if ($breadcrumb && (strstr($breadcrumb," &raquo; ") || strstr($breadcrumb," » "))):
    print
$breadcrumb; endif;
?>

If $breadcrumb on a page returns one of these examples:

home

anything

The $breadcrumb will not print.

If $breadcrumb on a page returns one of these examples:

home »

home » hahaha

anything » moo

»

The $breadcrumb will show. The first and last are likely to occur with phptemplate_breadcrumb($breadcrumb) is overridden or a module interfering with breadcrumbs. Back in real life, drupal setup's often include many modules which may trigger this extraneous result. So we look for a fix.

A cooler way

Inside: template.php in your theme folder
I have made a function override for phptemplate_breadcrumb($breadcrumb). This override grants some flexibility, and best of all you can stick keep your old

<?php
print $breadcrumb
?>
function call in page.tpl.php. Inside your theme's directory find template.php (if it isn't there, create it.) Paste this function in:

<?php
/*
    phptemplate_breadcrumb($breadcrumb) override
    File: template.php
    Use: Hide breadcrumb trails with only 1 crumb, regardless of crumb name ("home" is)
        a popular single-crumb that people like to have removed in some templates.
    Through: PHPTemplate function override
    Benefits: Does not involve extra code in separate view.
*/
function phptemplate_breadcrumb($breadcrumb) {
   
$home = variable_get('site_name', 'drupal');
   
$sep = ' &raquo; ';
   
// Check if breadcrumb has more than 1 element.
    // Options: Change to the number of elements/crumbs a breadcrumb needs to be visible.
   
if (count($breadcrumb) > 1) {
       
$breadcrumb[0] = l(t($home), '');
       
/*
            Optional: Include page title in breadcrumb.
       
            drupal_get_title() !== ''
                Check if title blank, if that is the case, we cannot include trailing page name.
            strstr(end($breadcrumb),drupal_get_title()) == FALSE
                Some modules will make it so path or breadcrumb will involve duplication of
                title and node name (such as in the Events module) to remove this, simply
                take out  && strstr(end($breadcrumb),drupal_get_title()) == FALSE
           
            Use: Simply uncomment the if structure below (3 lines).
            Special Use: If you wish to use this regardless of elements/crumbs in a breadcrumb
                simply cut/paste the statements inside the "if (count($breadcrumb) > 1)" outside
                of the structure, and delete the extranneous structure.
   
            if ( (drupal_get_title() !== '') && (strstr(end($breadcrumb),drupal_get_title()) ) == FALSE) {
                $breadcrumb[] = t(drupal_get_title(), '');
            }
        */   
       
return implode($sep, $breadcrumb);
    } else {
       
// Would only show a single element/crumb (or none), so return nothing.
        // You can remove this statement.
   
}
}
?>

Remember, this function override is not meant to be coupled with the first example in page.tpl.php

<?php
print $breadcrumb
?>

to call your breadcrumbs.

works in 6.6?

idcm - October 25, 2008 - 12:30

I am rebuilding off-line from 4.6 to 6.6. I plugged this into the Marinelli theme and it seems to work. Thanks for sharing!

Remove Home Breadcrumb if Only Home

eugsadhu - June 21, 2007 - 01:53

function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb) && count($breadcrumb)>1) {
    return '<div class="breadcrumb">'. implode(' &#187; ', $breadcrumb) .'</div>';
  }
}

hide home completely

czeky - June 24, 2007 - 14:51

is there a way to hide "home" completely on every page?

thanx

Yes

lanjingyu - January 8, 2009 - 06:14

There is a way for your requirement:

function phptemplate_breadcrumb($breadcrumb) {
array_shift($breadcrumb);
if (!empty($breadcrumb)) {
return ''. implode('*****', $breadcrumb) .'';
}
}

thanks for this

ipwa - October 24, 2007 - 04:14

this worked really good for me, except that now all breadcrumbs have "?" rather than ">>" can anyone help?

Nicolas
-----------------
http://nic.ipwa.net

"?" rather than ">>

re-present - November 30, 2009 - 10:12

This often happens when cutting and pasting code via a broswer. Re-type the '>' in a plain text editor or look up the ASCI code for the character you'd like to use. This should fix this for you.

www.re-present.com | communications and design consultancy | open source / fashion / ideas for sustainability

This worked for me

jriddiough - July 21, 2007 - 09:52

I used this in the template.php file to remove whatever the "first" item in the breadcrumb is. Hope it helps

/**
* Return a themed breadcrumb trail.
*
* @param $breadcrumb
*   An array containing the breadcrumb links.
* @return a string containing the breadcrumb output.
*/
function phptemplate_breadcrumb($breadcrumb) {
unset($breadcrumb[0]);
array_unshift($breadcrumb, array_shift($breadcrumb) );

return '<div class="breadcrumb">'. implode(' &raquo; ', $breadcrumb) .'</div>';
}

Still works for drupal 5

levavie - February 2, 2008 - 19:40

This is what worked for me, on Drupal 5.

<?php
/*
* Only display breadcrumbs for nodes.
* Node breadcrumb display is further customized with the custom breadcrumbs module
* Hide breadcrumbs for 'biz' type nodes.
* Hide breadcrumbs on views or other non-node pages.
* Home link is modified to display the site name.
*/
function phptemplate_breadcrumb($breadcrumb) {
  if (
arg(0) == 'node' && is_numeric(arg(1)) ) {
   
$result = db_query("SELECT nid, type FROM {node} WHERE nid= %s", arg(1));
    if (
$result) { // This is a node.
     
$node = db_fetch_object($result);
      if (
$node->type != 'biz') {
       
/* Replace the first breadcrumb element (ususlly 'home') with the site name */
       
$home = variable_get('site_name', 'drupal');
       
$breadcrumb[0] = l(t($home), '');
       
/* Add the breadcrumb returned by the 'custom breadcrumb' module. . */
       
return theme_breadcrumb($breadcrumb);
      }
    } else {
     
// Don't show breadcrumbs for non-node elements (e.g. for views).
     
return '';
    }
  }
}
?>

Amnon
-
Professional: Drupal Israel | Drupal Development & Consulting
Personal: Hitech Dolphin: Regain Simple Joy :)

have an update for that on

KrisBulman - August 1, 2008 - 01:05

have an update for that on drupal 5.9?

=-=

VM - August 1, 2008 - 01:17

what errors are you getting that don't allow it to work on 5.9 ?

thanks for that, it works

leetamus - January 28, 2009 - 18:49

thanks for that, it works perfectly for me ;)

Worked for me in 6.3.

Rob T - September 3, 2008 - 00:21

This solution a few posts above works for me in 6.3.

To remove home sitewide but not necessarily the first breadcrumb

pushdesign - June 29, 2009 - 17:47

This solution worked, but on pages like 'About' you would lose the breadcrumb simply because it was first. I only needed the 'Home' to be removed to this is what worked for me.

function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    // add the current page title to the breadcrumb
if (drupal_get_title()!='Home'){
    $breadcrumb[] = '<span class="active">'. drupal_get_title() .'</span>';
if ($breadcrumb[0]='Home'){
unset($breadcrumb[0]);
array_unshift($breadcrumb, array_shift($breadcrumb) );
return '<div class="breadcrumb">'. implode(' / ', $breadcrumb) .'</div>';
}else {
    return '<div class="breadcrumb">'. implode(' / ', $breadcrumb) .'</div>';
}
}
  }
}

Works in Drupal 6.13

d3zign7reak - August 20, 2009 - 15:37

The above solution worked for me on a Drupal 6.13 installation.

------------------------------------------
Alvin Crespo
Interactive Developer and Designer

Why not simplify?

Justin W Freeman - October 1, 2009 - 05:57

Why not just:?

/**
* Return a themed breadcrumb trail.
*
* @param $breadcrumb
*   An array containing the breadcrumb links.
* @return a string containing the breadcrumb output.
*/
function phptemplate_breadcrumb($breadcrumb) {
  array_shift($breadcrumb);
  return '<div class="breadcrumb">'. implode(' &raquo; ', $breadcrumb) .'</div>';
}

Thanks, jriddiough

jcipriani - October 24, 2009 - 19:22

Thanks, jriddiough. Worked perfectly.

Update for 6.x

teejaydub - October 10, 2008 - 20:37

For those finding this by searching, as I did - Note that http://drupal.org/project/menu_breadcrumb does this now with no (extra) code.
--tjw

no it doesn not do what ppl

deepM - April 29, 2009 - 13:01

no it doesn not do what ppl were asking for, just part of it.

Great

ruess - September 29, 2009 - 04:59

Actually this solution above really helped me. Thank you!

Removing home link - thanks!

asterix - October 27, 2008 - 21:56

Hi jriddiough - your solution (removing only the "home" link in the breadcrumb) is just what I was looking for and works like a charm - thanks!

Alex
----------
Contract Web Development, Inc.

Hye jriddiough, I'm newbie to

letsnurture - March 23, 2009 - 13:41

Hye jriddiough,

I'm newbie to the drupal and I have been playing with the drupal for few couple of week. Before that I worked with Zend-Framework,Oscommerce,Moodle-online course management system.

Today, I created some nodes of type 'page' to taste the drupal CMS and I found that when browser renders those page, it also presents the 'Home'-root of the drupal breadcrumb.And it looks awkward as it appears top of the each page.

So all of sudden, I deleted the $breadcrumb from the page.tpl.page but then I got a question what if some page needs to have breadcrumb.So this is not the good practice ever.

So finally, I reached here and grabbed this place and now everything goes well.

Thanks for leading to the end of the tunnel and to lighten the lamp to eliminate the darkness

Web-Farmer
------------
www.letsnurture.com

I have tried everything i can

dbeall - March 27, 2009 - 21:07

I have tried everything i can find on these breadcrumbs.. nothing works to remove the single 'home' link. Is this some kind of bug that needs to be filed someplace? Maybe there is a way to tell custom breadcrumbs to NOT display by content type? I have tried the php visible false thing , and that don't work either... maybe we are just suppose to not use any breadcrumbs at all..........In fact, none of the php code in this tread seems to work either. I don't get it...drupal is suppose to be ahead of it's time, maybe the breadcrumbs are from the past...don't know

custom breadcrumbs 2.0

MGN - June 13, 2009 - 02:38

Is there anyway to either:

1) globally remove 'Home" from ALL breadcrumbs
2) specifically remove 'Home' on breadcrumbs of certain pages

And as a side question:

3) Is there any way to include the current page/node being viewed as the last "crumb" in the breadcrumb trail?

This is now possible in the 6.x-2.x-dev version of custom_breadcrumbs

There is a global configuration for setting the text of the Home breadcrumb, and you can also just eliminate it. To add it back in on some pages, node-types, views, taxonomy-pages, or at specific paths, you'll just add Home (or whatever text you want) as the first title in the breadcrumb.

For the title of the page (node) being viewed, just use the [title] token (provided by the Token module).

This version is still in development, but ready for testing.

that sounds great but it just

vthirteen - August 5, 2009 - 17:55

that sounds great but it just doesn't work for me.
see my post in the custom breadrcrumbs issue queue at http://drupal.org/node/407052#comment-1892310

the php function from the above post http://drupal.org/node/103174#comment-1756386 (thank you!) is what i used not to print the "Home" crumb by default.

MGN's reply here

vthirteen - August 6, 2009 - 07:57

MGN's reply here http://drupal.org/node/407052#comment-1893964 actually solved the problem with and within custom breadcrumbs module.

.

dbeall - September 4, 2009 - 17:17

I have switched to the dev version of custom breadcrumbs and it's really great. All my issues with breadcrumbs seem to be solved now, life is good..

 
 

Drupal is a registered trademark of Dries Buytaert.