Hide 'Home' link only on a breadcrumb
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
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
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)
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):
<?phpif (isset($breadcrumb)) {
// delete this whole if structure, including its inner statements.
}
?>
or Find:
<?phpprint $breadcrumb
?>
Replace with:
<?phpif ($breadcrumb && (strstr($breadcrumb," » ") || strstr($breadcrumb," » "))):
print $breadcrumb; endif;
?>
If $breadcrumb on a page returns one of these examples:
The $breadcrumb will not print.
If $breadcrumb on a page returns one of these examples:
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
<?phpprint $breadcrumb
?>
<?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 = ' » ';
// 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
<?phpprint $breadcrumb
?>
to call your breadcrumbs.
works in 6.6?
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
function phptemplate_breadcrumb($breadcrumb) {if (!empty($breadcrumb) && count($breadcrumb)>1) {
return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';
}
}
hide home completely
is there a way to hide "home" completely on every page?
thanx
Yes
There is a way for your requirement:
function phptemplate_breadcrumb($breadcrumb) {
array_shift($breadcrumb);
if (!empty($breadcrumb)) {
return ''. implode('*****', $breadcrumb) .'';
}
}
thanks for this
this worked really good for me, except that now all breadcrumbs have "?" rather than ">>" can anyone help?
Nicolas
-----------------
http://nic.ipwa.net
"?" rather than ">>
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
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(' » ', $breadcrumb) .'</div>';
}
Still works for drupal 5
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
have an update for that on drupal 5.9?
=-=
what errors are you getting that don't allow it to work on 5.9 ?
thanks for that, it works
thanks for that, it works perfectly for me ;)
Worked for me in 6.3.
This solution a few posts above works for me in 6.3.
To remove home sitewide but not necessarily the first breadcrumb
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
The above solution worked for me on a Drupal 6.13 installation.
------------------------------------------
Alvin Crespo
Interactive Developer and Designer
Why not simplify?
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(' » ', $breadcrumb) .'</div>';
}
Thanks, jriddiough
Thanks, jriddiough. Worked perfectly.
Update for 6.x
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
no it doesn not do what ppl were asking for, just part of it.
Great
Actually this solution above really helped me. Thank you!
Removing home link - thanks!
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
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
Letsnurture
http://www.letsnurture.co.cc/
I have tried everything i can
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
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
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
MGN's reply here http://drupal.org/node/407052#comment-1893964 actually solved the problem with and within custom breadcrumbs module.
.
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..