How do you get breadcrumbs to show the current page?
Post installationbobo - May 4, 2005 - 21:53
How to I get breacrumbs to show the current page, whether it be "home" or if I am viewing a book page so that the breadcrumbs also includes that page.
I.e. I am viewing, "Drupal" in "help" in "stuff" so that it shows home >> stuff >> help >> Drupal instead of home >> stuff >> help ??
I.e. see: http://aucklandanimalaction.org.nz/2/foiegras
Instead of saying:
Home » Issues » Foiegras
it says
Home » Issues
Yours,
Simon
» Add new comment
One idea via theming
laura s - May 4, 2005 - 23:54
What if you added the title right after the breadcrumb in page.php.tpl? (You would need phpTemplate to do this.) In fact, I'm going to go try it right now as it sounds like it might be a nice feature.
.:| Laura • pingV |:.
reply
Got it
laura s - May 5, 2005 - 00:07
Find your breadcrumb in page.php.tpl and edit the line to read:
<?php print $breadcrumb ?><?php if ($title != ""): ?>» <?php print $title ?><?php endif; ?>
You will need to wrap this in a div class or id tag and style the class or id in your style.css file to include display: inline. This will add the current page title to the end of the breadcrumb, without a link, which is the norm I've seen on many sites.
Hope this helps!
.:| Laura • pingV |:.
reply
thanks
bobo - May 10, 2005 - 03:11
Thanks laura, but I can't find page.php.tpl... I think I'm using xtemplate, not phptemplate.
Yours,
Simon
reply
Xtemplate might not work
Steven - May 10, 2005 - 03:33
You can try adding the page title tag to that place in the .xtmpl (I think it's {title}) but if you want to do any sort of advanced theming, then XTemplate is not the way. You can only override the basic page elements. With PHPtemplate on the other hand, you can access the full theming abilities of Drupal.
There is a recent thread which compares XTemplate and PHPTemplate.
--
If you have a problem, please search before posting a question.
reply
An example
dordal - May 8, 2006 - 22:47
Here is an example of the full code for laura's post above, including adding the display:inline to the definition of .breadcrumb in your style sheet, and the "div class='breadcrumb'" around your $title. Thought it might be helpful for anyone who was just copying code, as I was.
So, in page.php.tpl:
<?php print $breadcrumb ?><?php if ($title != ""): ?><div class="breadcrumb">» <?php print $title ?></div><?php endif; ?>
and in your style.css:
.breadcrumb {
display:inline;
padding-bottom: .5em;
}
reply
Another example
j-clark - March 5, 2008 - 10:46
That example didn't work for me, playing with the Garland theme.
I got it to do what I wanted by changing the phptemplate_breadcrumb function in template.php as follows:
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$title = drupal_get_title();
if (!empty($title)) {
$breadcrumb[]=$title;
}
return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
}
}
Just in case anybody else wants to do this.
P.S. I am a complete newbie, so if this is a rubbish method, please tell me.
reply
Works great!
kost - March 17, 2008 - 20:44
Thanks. Nice solution.
reply
It is considered bad
Venkat-Rk - May 5, 2005 - 07:56
It is considered bad usability practice to point to the current page on the breadcrumbs since you are already there- it is like showing a 'Home' link on the home page of a site.
See the section titled, "Third bug: taxonomy breadcrumbs include the current term" on this page for an explanation:
http://www.greenash.net.au/posts/thoughts/basic_breadcrumbs_and_taxonomy
reply
A matter of taste, need and design
laura s - May 6, 2005 - 08:32
I have seen more standard practice in the direction of showing the actual page as unlinked text. Go through the Yahoo directories, for example, and you will see the current directory listed right there at the end of the breadcrumbs.
I looked at the article you cited. It has some interesting ideas, but I would beg to differ on the issue of breadcrumbs.
Try viewing a node: you will see that the breadcrumb trail includes the parent terms of that page, but that the current page itself is not included. This is how it should be: you don't want the current page at the end of the breadcrumb, because you can determine the current page by looking at the title!
That depends on your site design. If your title is right there, then you're right, perhaps it's not needed. But if your title is far away from the breadcrumbs, it's a different story.
And also, each part of the breadcrumb trail is a link, so if the current page is part of the trail, then every page on your site has a link to itself (very unprofessional).
Ah, but there is no link for the current page -- it's just text.
To me, in the article cited there are assumptions about design and blanket rules that don't always apply. AFAIK, there's no consensus against the current page's being included in breadcrumbs. If there were, you could consider me a rebel for not automatically marching in step. ;)
.:| Laura • pingV |:.
reply
Up to each webmaster
Jaza - May 10, 2005 - 05:43
As the author of the cited article, I must agree with you in saying that it's a matter of individual taste whether or not the breadcrumb trail should include the current page. As you can tell by reading my article, I have a very strong personal preference for breadcrumbs that don't include the current page. But I was stating my opinion, not dictating any rules.
There are no doubt some designs where one type of breadcrumbs would look better than in other designs. Just use the style that suits your page layout best - if the title is not displayed prominently on your pages, then maybe it is appropriate to show it in the breadcrumb trail. Also, having the current page breadcrumb not as a link is good - I think this helps.
Jeremy Epstein - GreenAsh
replyActive page in breadcrumb
brooklynwebguy - May 5, 2007 - 23:09
My preference is for just showing everything above the page in the trail. However if the last one representing the active page is not linked but simply text that is formatted in a way that clearly distinguishes it from the other items, I don't think that damages any user expectations and therefore the two approaches can co-exist.
That last active page breadcrumb should never be link, though, because then that really does suggest it represents something other than the page the user is on. And regardless of where your breadcrumb trail is, the page title should be prominent and in one of the zones where the user expects to find it. It is only through a common set of conventions that users make their way around the internet morass. If you flout them, there should be sound functional reasons for doing so.
replyI know this is an old topic, but..
krikette - September 13, 2007 - 14:18
From a usability standpoint, it is NOT more user-friendly to leave the current page off of the breadcrumb. It isn't crippling, and it's not really that big of a deal, but every new user has a certain amount of time they will spend on a site before they wander off. Every split second that they spend confused or lost eventually adds to this time and if enough things make them stop and feel confused, they will leave.
There are instances where it could potentially confuse someone however briefly by not having the current page at the end of the breadcrumb, because most people will be expecting the last item to be the place they are at. When this doesn't match the page title they could be confused. If the last item on the breadcrumb is your page title and it links to itself, it may be confusing also.
Note that I use "confusing" here to mean more of "users may stop to wonder why it was done that way". Most people will not care, however there are some that may wonder about it.
I just wanted to rebuff the article's tone and insistance that it is unprofessional to be redundant in web design.
replyI would like to echo my STRONG agreement
MikeSchinkel - November 4, 2007 - 03:11
I have seen more standard practice in the direction of showing the actual page as unlinked text. Go through the Yahoo directories, for example, and you will see the current directory listed right there at the end of the breadcrumbs.
Great comment laura s. I would like to echo my STRONG agreement with you on this.
As for websites that do not show a reference the current page as a non-linked title, I find those sites very unprofessional.
reply
Agreed!
vuxes - June 18, 2008 - 15:21
Not showing the current page as an unlinked text is like getting caught with your pants down!
Indeed, there is also the need to link the current "page" if there are more than one pages to your node. Say you click to a product review page, so the breadcrumb is: Home >> Reviews >> Product A. The review has 10 pages. In this case, we do want Product A to be displayed as a link so we can quickly return to the beginning of the review (whether you consider it to be page 1 or intro or title page, whatever) as well as provide the links for the 10 pages at the bottom of each page.
Please do not get caught into the strict definition of stuff, guys. Just get practical. Or, just give people the choice.
reply
It depends where you use breadcrumb for!
Bèr Kessels - May 18, 2006 - 12:54
If you use it to point users where they are NOW, then including the current page is a good thing (see it as that "you are here mark" on maps).
But one should carefully consider whether or not to make it a link.
---
Professional | Personal
| Sympal: Development and Hosting
reply
"But one should carefully
schnizZzla - May 5, 2007 - 23:03
"But one should carefully consider whether or not to make it a link."
Why would you not make it a link?
reply
what's the point?
jenlampton - May 25, 2007 - 00:57
The link would just take people to the page they are already on. It's self-referential, and even though I think it can be helpful to include the active page in the breadcrumbs, it should not be linked.
Jen
*~ current project: www.customerthink.com ~*
reply
Not true
solipsist - August 24, 2006 - 00:20
I disagree, anything but showing the current document name is very confusing, for a number of reasons.
--
Jakob Persson
web design and usability consulting
http://www.jakob-persson.com
replyThe main consideration is spider/search engine performance, no?
k9gardner - February 19, 2008 - 21:14
Beyond anyone's personal preference for how it ought to be done, or whether it's considered good form to have a self-referential link on a page, I can see no factor more significant than what a search engine needs or wants to see on a site to determine what should be presented. The SEO folks that my company is working with are telling me that breadcrumbs are incredibly important for spidering, and who am I to disagree? I just want to deliver the destination needed so that their targeting will work optimally.
Specifically, according to this way of looking at it, the highest order qualifier should not be "home", but should probably be the domain. And the lowest order should in fact be the page you're on.
I am incredibly new to Drupal, and now apparently I need to install something I don't have, as I have not made myself aware of any plugin modules until the need has arisen. Now that the need has arisen, I'm a little surprised that I have to use taxonomy or install something like phpTemplate in order to create effective breadcrumbs, but so be it. At least – and this is a very very good and big thing – there is a community of developers out there who can and will and have the knowledge to share with others. Thanks everyone.
replyU R Here
gregarios - February 21, 2009 - 18:06
newI guess all those signs, worldwide, that have local map which points out where you are with a "You Are Here" on it are considered bad too? lol
I think looking at the breadcrumbs to see exactly where you are is handy sometimes. :-)
reply
perhaps my prob is similar
Downward Spiral - May 10, 2005 - 05:55
perhaps my prob is similar to that... my favicon is in the root-directory, but only shown, when bookmarking the homepage... every "?q="-site is bookmarked without the favicon... :(
replyI'm with Laura
twohills - March 10, 2006 - 05:03
To me it looks counter-intuitive to NOT have the current page in the breadcrumb trail.
the approach of having it there but not an active link makes perfect sense to me and looks the most natural to me.
I'm forever getting momentarily confused by the Drupal breadcrumbs for this reason (I must have a goldfish brain, it gets me over and over)
reply
Here's a hack to get breadcrumb for current page
twohills - March 24, 2006 - 00:23
if you don't mind that the breadcrumb for the current page is a clickable link, then it is as simple as commenting out this line in menu.inc in function menu_get_active_breadcrumb()
array_pop($links);
it doesn't work quite right for project_issues but generally it's great
reply
Or if you don't want it as a
plong0 - July 18, 2007 - 22:19
Or if you don't want it as a link and wish only to show the title...
leave array_pop($links); uncommented
after it add $links[] = drupal_get_title();
works as a beauty for my needs :D
reply
With Taxonomy Breadcrumb
plong0 - July 18, 2007 - 22:38
After messing with it I decided I wanted the taxonomy hierarchy to be used for breadcrumbs plus showing the current node page as not a link... it can be done as so...
install and activate the http://drupal.org/project/taxonomy_breadcrumb module
leave checked the "Show current term in breadcrumb trail?" option
she works nicely, but! when you're viewing a page it doesn't show this node in breadcrumbs??
I fixed it in this way...
for your file: modules\taxonomy_breadcrumb\taxonomy_breadcrumb.module
under function of: taxonomy_breadcrumb_generate_breadcrumb($tid, $is_term_page = FALSE)
Locate line: // Do not create links to own self if we are on a taxonomy/term page.
make changes as such:
// Do not create links to own self if we are on a taxonomy/term page.
/** if ($is_term_page && $parent_term->tid == $tid) {
$breadcrumb[] = $parent_term->name;
}
else {*/
//never add own self to the breadcrumb here
if (!($is_term_page && $parent_term->tid == $tid)) {
$breadcrumb[] = l($parent_term->name, $term_path);
}
Locate line: return $breadcrumb;
Before him add:
//add ourself to the breadcrumb here
$breadcrumb[] = drupal_get_title();
now it does my bidding, and can do your's too!!
I am not sure if this is the best solution, but it seems to work as I need. Please let me know if you have a better way?
replyto avoid that the current page is a link but just a title
BassPlaya - August 19, 2007 - 11:36
doesn't really work for me with plong0 example:
actually I think I'm doing something wrong but don't know what.. it shows up like this: administer » settings » settings where the first "settings" is not a link but the last one is..
here's my code:
...
$item = menu_get_item($mid);
if ($item['type'] & MENU_VISIBLE_IN_BREADCRUMB) {
$links[] = menu_item_link($mid);
}
}
// The last item in the trail is the page title; don't display it here.
array_pop($links); $links[] = drupal_get_title();
return $links;
}
any solutions?
replyOr if you don't want it as a
tyler-durden - June 20, 2008 - 12:34
Or if you don't want it as a link and wish only to show the title...
leave array_pop($links); uncommented
after it add $links[] = drupal_get_title();
works as a beauty for my needs :D
This works for me, but i'd like to know how to use the menu title instead of the page title. Is there a way? Thanks!
reply
theme override is the best (but more complex)
Bèr Kessels - May 18, 2006 - 12:52
You can override the breadcrumb generation in your theme:
<?php
function mytheme_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$breadcrumb[] = drupal_get_title();
return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';
}
}
?>
.. Is all you need to add to your template.php
This will NOT make the title a lin though. In order to do that, you need to change the line $breadcrumb[] = drupal_get_title(); into $breadcrumb[] = l(drupal_get_title(), $_GET['q']);
---
Professional | Personal
| Sympal: Development and Hosting
reply
Nice fix, thanks
twohills - May 18, 2006 - 21:38
A nice hook that requires no code changes, thankyou for that.
I've stopped using breadcrumbs for a more fundamental reason. I opened a new thread for it http://drupal.org/node/64348
replyKiCK ASS!
Zach Harkey - June 14, 2006 - 15:48
This is how breadcrumbs should work imho.
What's the best way to get this added to the PHPTemplate Theme Snippets section of the handbook?
-zach
--
harkey design
replyThanks
karldied - July 1, 2006 - 07:11
Thanks for the code suggestion, which I put in my template.php, and it works.
I'm with the camp that likes 'home' and the 'current page' in the bread crumb trail, to help site visitors (generally not expert surfers in my case) understand at least one area of the site they may be in.
I'm less sure how to make the current page "gray" using the style sheet while keeping the carrots black (which I like to do to make it even more obvious that it is the 'current page' location).
For some reason, the » (>>) turned into a question mark, so I substituted a single > in the suggested code, and that makes all the separators into single >, which is my preference anyway.
-Karl
reply
Error message
karldied - July 11, 2006 - 06:22
This code snippet seemed to work when I first installed it, but now gives a double error when trying to log in:
Cannot modify header information - headers already sent ...
session_regenerate_id(): Cannot send session cookie - ...
And error message content of:
session_regenerate_id(): Cannot send session cookie - headers already sent by (output started at /home/karld/lesvoyageurs/html/d/themes/lvtheme/template.php:27) in /home/karld/lesvoyageurs/html/d/modules/user.module on line 943.
Line 27 of template.php is the start of the code <?php
release 4.7.1 (pretty sure...)
reply
Tip to make this work
Als - December 4, 2006 - 22:38
Thanks Bèr, yours is a nice solution.
It is worth adding that to make this snippet work it is necessary to substitute 'mytheme' in the function with the actual theme name. :-)
replyNice
kimangroo - June 7, 2007 - 08:24
Thanks for that. I had to replace ' » ' with ' » ' to get the proper delimiter thingy.
reply
How about removing 'home' from breadcrumb?
kayfish - May 22, 2006 - 00:00
i would actually like to -remove- the HOME link from the breadcrumb. It is very redundant on my site - It's in the primary navigation and the user can also click on my icon. When I'm one level down in my hierarchy, the 'home' link is very distracting.
Does anyone have any suggestions on how I might do this?
THanks!
reply
If you want your breadcrumbs
_craig - May 25, 2006 - 01:46
If you want your breadcrumbs to follow your taxonomy structure, check out taxonomy_breadcrumb. After installing, you can go to /admin/settings/taxonomy_breadcrumb to remove (or change) the "Home" breadcrumb.
replyremove 'home' using phptemplate override
here - June 9, 2006 - 01:04
The following override also works quite simply to remove the first element from the breadcrumb trail. Put the code in your theme's template.php .
<?php
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$breadcrumb[] = drupal_get_title();
array_shift($breadcrumb);
return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';
}
}
?>
don't forget to expand the '»' back out to '& #187;' (no space) in the code.
reply
Get rid of node title in breadcrumb
ludoal - September 6, 2006 - 11:08
Thanks for your snippet.
I added array_pop($breadcrumb); just after the array_shift function to get rid of the current node title in the breadcrumb.
reply
Removing the breadcrumb
fseraphine - August 11, 2006 - 07:25
The easiest way to remove the breadcrumb is to change the drupal.css.
In drupal\misc edit drupal.css and change
.breadcrumb {
padding-bottom: .5em;
}
to
.breadcrumb {
padding-bottom: .5em;
display: none;
}
Et voilà, the breadcrumb doesn't appear anymore if the theme doesn't override the basic CSS with "display: something ! important;".
reply
Tip to make this work
Als - December 4, 2006 - 22:35
---> This comment was put in the wrong position and has been moved by author <--
replyRE: How do you get breadcrumbs to show the current page?
intfocus - January 30, 2008 - 13:58
I found another alternative to the current responses listed:
Open /includes/menu.inc and scroll down to line 547 which should read:
// The last item in the trail is the page title; don't display it here.
array_pop($links);
Comment out array_pop($links); to allow you to backtrack in case you want to revert your changes.
Code Source:
- http://api.drupal.org/api/function/menu_get_active_breadcrumb/6 (Drupal Function)
- http://www.php.net/array_pop (in case you want to know what it does)
Note:
- Using this example will NOT remove the current page link. But it's easier than recoding your template.php file.
- This method returns the Menu Link Title NOT the Page Title (I prefer this - since it allows me to use keywords in my titles). If you want your Page Title to appear, use Bèr Kessels' method.
Enjoy!
replyshow current page?
PinkChocobo - February 19, 2008 - 17:06
Hi there,
I'm having a similar problem, but I'm having issues trying to fix this with little php experience. The breadcrumbs work for the administer pages, but on all other page it simply says "home" and does not add breadcrumbs when I get further into the site. I've seen other posts with this complaint, and after trying the fixes I still can't get it to work.
template.php:
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
return '<div class="breadcrumb">'. implode(' » ', $breadcrumb) .'</div>';
}
}
page.tpl.php:
<div id="main">
<?php if ($title != ""): ?>
<?php print $breadcrumb ?>
<h1 class="title"><?php print $title ?></h1>
reply
taxonomy works
PinkChocobo - February 19, 2008 - 19:08
the taxonomy breadcrumbs took care of this issue
reply
A less obtrusive solution
tobiassjosten - August 26, 2008 - 20:05
My suggestion is to use the contributed module Custom Breadcrumbs to solve this, with the setup I explain in another thread.
reply
phptemplate_breadcrumb not working
gownikarunakar - February 1, 2009 - 13:19
newHi,
I have tried using phptemplate_breadcrumb() function to manipulate the breadcrumb but there is no change in the pages.
Can anyone help on how to change the breadcrumbs on the pages?
I have only added the above function in the template.php file.
Thanks in Advance
Karunakar
Sunday, March 1, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment