How to alter/hide breadcrumbs
Hello everyone!
I'm wondering how I can hide breadcrumbs, when there is only one item visible (which is usually Home
).
Best Answers
-
Linc Admin
You could do this with CSS by targetting the pages on which it is only 1 item using their unique classes on the body tag.
My recommendation would be to leave the breadcrumbs so they don't disappear/reappear which is a much more confusing experience than the slight annoyance of having the same link there so much.
5 -
hgtonight MVP
While I agree with @Lincoln in that you shouldn't remove it, here is a technique you can use to remove the breadcrumbs when there is only 1 level site wide:
public function Base_Render_Before($Sender) { if(count($Sender->Data['Breadcrumbs']) == 1) { array_shift($Sender->Data['Breadcrumbs']); } }
Add it to your themehooks or plugin.
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
5
Answers
You could do this with CSS by targetting the pages on which it is only 1 item using their unique classes on the body tag.
My recommendation would be to leave the breadcrumbs so they don't disappear/reappear which is a much more confusing experience than the slight annoyance of having the same link there so much.
While I agree with @Lincoln in that you shouldn't remove it, here is a technique you can use to remove the breadcrumbs when there is only 1 level site wide:
Add it to your themehooks or plugin.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
@hgtonight: Sorry, I already accepted you answer - but somehow I didn't get it to work.
After a little debugging I realized, that there is no "Home"-Breadcrumb in the Breadcrumbs array. That means, the Breadcrumb is generated somewhere else.
Alright... Did you want the homelink to appear when there is more than 1 item?
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Ah sorry, that was kind of a misunderstanding then
I thought
Home
is its own breadcrumb.Yes I meant, when there is no other breadcrumb than
Home
it should be hidden. I now resolved it with CSS as Lincoln mentioned.But if there is a solution with PHP, that would be even better.
You would have to use
{breadcrumbs homelink="false"}
in your template file and then add the home link back in if you detected any items in the breadcrumb data array. Something like this:Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Almost! Now I get
false
instead ofHome
and without the quotes I get the actual title.I guess I need to stick with the CSS solution. but thank you!
Sorry, it should be
{breadcrumbs homelink=false}
. I added the quotes by accident.Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
I tried the code from this post http://vanillaforums.org/discussion/comment/206447/#Comment_206447, but it is still there.
I want to remove the breadcrumb from the homepage. It's not very useful to show a link back to the homepage when we are already on the homepage.
I created a class.bootstrapthemehooks.php in the bootstrap theme folder and placed the following code in it:
[php]
class BootStrapThemeHooks implements Gdn_IPlugin {
}
[/php]
But nothing happens, the breadcrumb is still there on the homepage. Anything else I can try?
An alternative way that I could fix it would be to have a 'home' class somewhere that is only added to the body tag on the homepage, but not sure how to do that.
I don't know how to do it without testing myself, but I would do that in order to find out how the breadcrumbs might be hidden:
The output of decho() is only visible for admins, so you have to be logged in with an admin account when you do that. Look at the home page and look also at another page in order to see what you have to check for when you want to hide the breadcrumbs.