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.

Breadcrumbs

Hi All,

I have my site pretty much the way I want it, but I'm having a slight issue modifying the breadcrumbs. I've edited them so that they display the page/thread title, but when someone goes to edit their post, or something else that would already generate a breadcrumb, it's showing "Home › General › Edit Discussion › Edit Discussion"

Is there a way to remove the first Edit Discussion, since it's already listed there where I put it manually?

«1

Comments

  • Welcome to the community!

    What version of Vanilla are you running?

    How did you implement your current breadcrumb modification?

    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.

  • precisely what i thought. :)

    @hgtonight said:
    Welcome to the community!

    What version of Vanilla are you running?

    How did you implement your current breadcrumb modification?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Sorry for the delayed reply!

    {breadcrumbs} <span class="Breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><span class="Crumb"> &rsaquo; </span><span itemprop="title">{$Title}</span></span> is what I'm using in default.master.tpl to achieve what I want, hackey I know.

    We're running on the latest version off the GitHub.

  • peregrineperegrine MVP
    edited July 2013

    We're running on the latest version off the GitHub.

    and we say again what version is that? It's not that hard to put a number in, provided you want help.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Apologies. We're running v2.2

  • hgtonighthgtonight MVP
    edited July 2013

    Breadcrumbs are wildly diverse in Vanilla.

    You could use a theme hook to add the page title as the last breadcrumb only if it would be different.

    Something like:

    public function Base_Render_Before($Sender) {
      $crumbs =& $Sender->Data['Breadcrumbs'];
      $crouton = count($crumbs);
      if($crumbs[$crouton - 1]['Name'] != $Sender->Data['Title']) {
        $crumbs[$crouton]['Name'] = $Sender->Data['Title'];
        $crumbs[$crouton]['Url'] = '#';
      }
    }
    

    If you use this, you should remove your previous modification to the default.master.tpl file. {breadcrumbs} is all that is needed. :D

    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.

  • hgtonighthgtonight MVP
    edited July 2013

    See above. I forgot I can edit posts by clicking on the gear icon that appears when hovering over a post and selecting Edit.

    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

    I got to the themehooks part but never coded anything :) , but i was thinking of removing based on post controller or adding if not post controller, but I I like yours better.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Tossed that in and it just made Vanilla start throwing a 500 error :(

    +1 for the try though, I appreciate it! I've never used theme hooks, and not even close to a coder, lol.

  • peregrineperegrine MVP
    edited July 2013

    in your tpl file - this will print normal breadcrumbs with title you wanted and will not print duplicates of edit discussions. So based on what you said - I believe this is what you want

    @stapler2025

     {if $Title ==  "Edit Discussion"}
         {breadcrumbs}
         {else}
         {breadcrumbs}
        <span class="Breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><span class="Crumb"> &rsaquo; </span><span itemprop="title">{$Title}</span></span>
        {/if}
    

    but you didn't mention the problem duplicates everywhere - not just edit discussion, it duplicates categories too.

    So hgtonight's solution is better.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited July 2013

    try this :)@stapler2025

      {if ($Discussion.DiscussionID <  "1")  || ($Title ==  "Edit Discussion")}
         {breadcrumbs}
         {else}
         {breadcrumbs}
        <span class="Breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb"><span class="Crumb"> &rsaquo; </span><span itemprop="title">{$Title}</span></span>
        {/if}
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @stapler2025 said:
    Tossed that in and it just made Vanilla start throwing a 500 error :(

    I tested it working on 2.1b1, but could you post the full error?

    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.

  • peregrineperegrine MVP
    edited July 2013

    hey @hgtonight

    what do you thin about --

    http://vanillaforums.org/discussion/comment/187964/#Comment_187964

    too restrictive?? it works though - he didn't have a working link before in the title, it seems overkill anyway.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @hgtonight said:
    I tested it working on 2.1b1, but could you post the full error?

    First error was [19-Jul-2013 02:13:25 UTC] PHP Parse error: syntax error, unexpected T_PUBLIC in /home/lsvps/public_html/vanilla/themes/default/class.defaultthemehooks.php on line 2 so I added class DefaultThemeHooks implements Gdn_IPlugin {

    Now I'm getting [19-Jul-2013 02:14:00 UTC] PHP Parse error: syntax error, unexpected $end, expecting T_FUNCTION in /home/lsvps/public_html/vanilla/themes/default/class.defaultthemehooks.php on line 12

    Thanks for your guys help :)

    @peregrine - what it's doing with how I have it setup using the title smarty tag, is anything that would already be in the breadcrumb bar, is basically duplicated. So if you're viewing a specific category, it lists Home - CategoryName - CategoryName, or starting a new discussion does Home - New Discussion - New Discussion, etc.

  • Those errors indicate your theme hooks file is not set up correctly.

    Mind posting the contents of your class.defaultthemehooks.php file?

    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.

  • <?php if (!defined('APPLICATION')) exit();
    
    class DefaultThemeHooks implements Gdn_IPlugin {
    
    public function Base_Render_Before($Sender) {
      $crumbs =& $Sender->Data['Breadcrumbs'];
      $crouton = count($crumbs);
      if($crumbs[$crouton - 1]['Name'] != $Sender->Data['Title']) {
        $crumbs[$crouton]['Name'] = $Sender->Data['Title'];
        $crumbs[$crouton]['Url'] = '#';
      }
    }
    
  • @stapler2025

    you may chose to use @hgtonight's solution in the long run.

    but doesn't the change i posted in relation to you tpl file work

    http://vanillaforums.org/discussion/comment/187964/#Comment_187964

    it doesn't duplicate anything as far as I can see

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine said:
    stapler2025

    you may chose to use hgtonight's solution in the long run.

    but doesn't the change i posted in relation to you tpl file work

    http://vanillaforums.org/discussion/comment/187964/#Comment_187964

    it doesn't duplicate anything as far as I can see

    Suuuuuuuper late reply, been busy.

    If I'm reading your's right, all it looks for is Edit Discussion, doesn't it?

  • peregrineperegrine MVP
    edited July 2013

    If I'm reading your's right, all it looks for is Edit Discussion, doesn't it?

    no , not true.

    all I can say is, try it. it worked for me. and if it doesn't work for you tell me exactly what doesn't work.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • come back in a couple of weeks :).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.