We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13577
    • 302 Posts
    This is an auto-generated support/comment thread for Breadcrumbs.

    Use this forum to post any comments about this addition or any questions you have regarding its use.

    Brief Description:
    Creates a highly configurable breadcrumb navigation trail.
      Standard Disclaimer
      I could be totally wrong.
      • 36747
      • 138 Posts
      I´m using this great snippet in a site (http://sabf.itba.edu.ar).

      The parameters i`m using are:
      $showHomeCrumb = 0;
      $showCurrentCrumb = 1;


      My site has 6 sections, in main page of each section I don´t wanna show the pagetrail because i´m getting the title of the that page twice, for example in my supporters section (http://sabf.itba.edu.ar/index.php?id=61) I have the ´Supporters´ of the pagetrail and the ´Supporters´ from the LongTitle.

      It`s possible not to show the breadcrumb if i`m getting just one page?

      Thanks in advance,
      eemi
        patagonia, argentina
        • 7923
        • 4,213 Posts
        Quote from: eemi at Jul 21, 2006, 09:05 PM

        It`s possible not to show the breadcrumb if i`m getting just one page?

        At the end of the snippet, replace

        return '<span class="B_crumbBox">'. join($ptarr, " $crumbSeparator ").'</span>';


        with

        if (count($ptarr)>1) {
        	return '<span class="B_crumbBox">'. join($ptarr, " $crumbSeparator ").'</span>';
        }


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 36747
          • 138 Posts
          Eventough I was looking to do it from the configuration, this solution is great. Thanks Doze!


          I think it´s a good option to let user show or not show the Breadcrumb if just one page is going to be listed.

          cheers
          emiliano
            patagonia, argentina
            • 4295
            • 98 Posts
            The Breadcrumbs snippet is great. I’m incorporating it on every page but homepage like this...
            Home >> Category >> Subcategory >> Content


            I would prefer for Breadcrumbs to display like this instead...
            Home >> Category >> Subcategory >>


            Note that I wish the last &raquo; (>>) to continue to display, just not the final child when you reach that page. I saw the span named ’.B_lastCrumb’ that surrounds the last crumb but this is a dynamic last crumb and not necessarily the real last child. I couldn’t find an UltimateChild-type parameter to turn off. Is this possible? If you reply, please remember, I’m a mortal, not a developer by trade. Thank you!
              • 4295
              • 98 Posts
              Quote from: bullrat at Sep 14, 2006, 06:42 PM

              The Breadcrumbs snippet is great. I’m incorporating it on every page but homepage like this...
              Home >> Category >> Subcategory >> Content


              I would prefer for Breadcrumbs to display like this instead...
              Home >> Category >> Subcategory >>


              Note that I wish the last &raquo; (>>) to continue to display, just not the final child when you reach that page. I saw the span named ’.B_lastCrumb’ that surrounds the last crumb but this is a dynamic last crumb and not necessarily the real last child. I couldn’t find an UltimateChild-type parameter to turn off. Is this possible? If you reply, please remember, I’m a mortal, not a developer by trade. Thank you!

              Okay, if you’re clueless like me and need the functionality I requested help on above -- here’s one possible method. I hate to hack a snippet as I don’t know what I’m doing, so use this at your own risk. The reason I needed the ultimate child to disappear in the BreadCrumb is so that I wouldn’t have redundant wording (once in the BreadCrumb and then again starting the page content).

              I replaced the code that doze mentions above using "<=3" instead of ">1" to ensure that all levels above my final content used the BreadCrumb as usual. You would need to set this number to reflect your own levels.

                  if (count($ptarr)<=3) {
              	return '<span class="B_crumbBox">'. join($ptarr, " $crumbSeparator ").'</span>';
                  }
              


              Then, below that, I forced the BreadCrumb output I wanted manually by backing up the breadcrumb trail. Again, I don’t know what I’m doing but this seems to work for me and perhaps this post will spur a coder to post the correctly coded solution. This is a great snippet but it would be even better with an UltimateChild parameter that could be toggled on or off. I hope this helps someone. Thanks!

                  if (count($ptarr)>3) {
              	return '<span class="B_crumbBox">'.$ptarr[count($ptarr)-4].'</span>' . " $crumbSeparator " .
                             '<span class="B_crumbBox">'.$ptarr[count($ptarr)-3].'</span>' . " $crumbSeparator " .
                             '<span class="B_crumbBox">'.$ptarr[count($ptarr)-2].'</span>' . " $crumbSeparator " ;
                  }
              
                • 7923
                • 4,213 Posts
                I could probably help, but I don’t understand what you want. Do you want to not show the page in the breadcrumbs if its the last visible item in the breadcrumbs and it’s the current page? if that’s the case, you can do it by replacing

                this:
                    $ptarr[count($ptarr)-1] = '<span class="B_lastCrumb">'.$ptarr[count($ptarr)-1].'</span>';

                with:
                    $needle = 'href="[~'.$modx->documentIdentifier.'~]"';
                    $found = strpos($ptarr[count($ptarr)-1], $needle);
                    if(!$found) {
                	$ptarr[count($ptarr)-1] = '<span class="B_lastCrumb">'.$ptarr[count($ptarr)-1].'</span>';
                    } else {
                	$ptarr[count($ptarr)-1] = ' ';
                    }
                


                EDIT: I did not test this, if there’s bugs, report and I’ll fix it.


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 4295
                  • 98 Posts
                  Hi doze, I tried the code you offered but it made the Breadcrumb disappear from every level. I’ll test whatever you come back with.

                  No rush if you’re hooked up -- as the hardcoded solution I came up with for my situation works fine -- but it would be good to have a proper fix for others needing similar solution. Thanks so much for your efforts. Have a good one.
                    • 7923
                    • 4,213 Posts
                    try changin !$found fo $found in the if clause (eg. remove !)


                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                      • 4295
                      • 98 Posts
                      My mistake earlier when I said the breadcrumb disappered when using your new code insert -- my bad.

                      WITH the "!" -- the breadcrumb does indeed work but there’s no change to the breadcrumb trail. WITHOUT the "!" -- the breadcrumb loses the crumb in the breadcrumb trail for the current page it’s on -- instead of just losing the crumb of the final absolute child. Thanks.