Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

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

Answers

  • @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.

  • hgtonighthgtonight ∞ · New Moderator

    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.

  • hgtonighthgtonight ∞ · New Moderator

    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:

    public function Base_Render_Before($Sender) {
      if(!empty($Sender->Data['Breadcrumbs'])) {
        array_unshift($Sender->Data['Breadcrumbs'], array('Name' => T('Home'), 'Url' => '/discussions'));
      }
    }
    

    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.

  • lumiolumio New
    edited April 2014

    Almost! Now I get false instead of Home and without the quotes I get the actual title.
    I guess I need to stick with the CSS solution. :) but thank you!

  • hgtonighthgtonight ∞ · New Moderator

    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.

  • TijmenTijmen New
    edited May 2015

    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 {

    public function Setup() {
        return TRUE;
    }
    
    public function OnDisable() {
       return TRUE;
    }
    
    public function Base_Render_Before( $Sender ) {
        if ( count( $Sender->Data['Breadcrumbs'] ) == 1 ) {
            array_shift( $Sender->Data['Breadcrumbs'] );
        }
    }
    

    }
    [/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.

  • R_JR_J Ex-Fanboy Munich Admin

    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:

    public function Base_Render_Before( $Sender ) {
        decho($Sender->Data['Breadcrumbs']);
    }
    

    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.

Sign In or Register to comment.