We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13292
    • 3 Posts
    Is there a way to make Breadcrumbs not show up on a particular page?
      • 25663 MODX Staff
      • 12,272 Posts
      You could create a separate template that doesn’t contain the call for those pages (that’s otherwise identical) or you could add a TV for containing your breadcrumb snippet call and remove it from that page or you could use PHx to perform a conditional test and remove the call if the page ID was a member of an array of page IDs.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 20159
        • 26 Posts
        Hi there

        Having a small problem with the text ModX is using for breadcrumbs.

        Breadcrumbs defaults to "pagetitle" as the text, however I want to use "menutitle". Therefore I added this parameter to the breadcrumbs call: [[Breadcrumbs? &titleField=`menutitle`]]

        Now this works perfectly when it shows parent links, but for active pages it still shows the pagetitle.

        You can see the problem here: http://www.waveconsulting.co.uk/new/application-consulting.html

        The active page breadcrumb should say "Application Consulting" but it instead defaults to the longer pagetitle.

        Can anyone help me resolve this?

        Many thanks
          • 7231
          • 4,205 Posts
          Have you tried calling the snippet uncached [! !]. Sometimes this helps issues with snippets.
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 20159
            • 26 Posts
            I tried [[!Breadcrumbs? &titleField=`menutitle`!]] which stops breadcrumbs working entirely. Did I get the syntaz right?
            Thanks
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              [!Breadcrumbs ... !]; you doubled the end brackets.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 6726
                • 7,075 Posts
                I’d like to tweak the Breadcrumbs snippet to have it use the menutitle if it’s not empty and the pagetitle if it is.

                // $titleField [string]
                // To change default page field to be used as
                // a breadcrumb title, default is pagetitle
                (isset($titleField)) ? $titleField : $titleField = 'pagetitle';
                


                Forgive my php, but I have tried this rolleyes

                [tt](isset($titleField)) ? $titleField : if ($menutitle!="") {$titleField = ’menutitle’;} else {$titleField = ’pagetitle’;}[/tt]




                  .: COO - Commerce Guys - Community Driven Innovation :.


                  MODx est l'outil id
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  All you have to do is pass it the parameter
                  [[Breadcrumbs? &titleField=`menutitle`]]

                  then it will try to use menutitle, and if that’s empty then it will use pagetitle. That is done in this line of the snippet code
                          $titleToShow = ($docInfo[$titleField])? $docInfo[$titleField] : $docInfo['pagetitle'] ;
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 6726
                    • 7,075 Posts
                    Oops how did I miss that rolleyes

                    Funny though I tried to do just that and I my breadcrumb did not appear anymore... maybe cache issue, thanks Susan I’ll check that !
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l'outil id
                      • 8894
                      • 114 Posts
                      Hello everybody !

                      For my site, my home page isn’t MODx [(site_start)] variable because the site start page contains a flash intro.
                      So, for my breadcrumb, I needed my "Home" link to be linked to my real home page, and I made a custom version of this snippet.
                      Maybe it can help someone else!

                      Usage: It adds a new parameter : $homePageId [number], which defaults to [(site_start)]
                      Example: [tt][!Breadcrumbs? &homePageId=`4`!][/tt]
                      Code:
                      <?php
                      // --------------------
                      // Snippet: Breadcrumbs
                      // --------------------
                      // Version: 0.9d
                      // Date: 2006.06.12
                      // [email protected]
                      // Honorable mentions:
                      // - Bill Wilson
                      // - [email protected]
                      // - grad
                      //
                      // This snippet was designed to show the path through the various
                      // levels of site structure back to the root. It is NOT necessarily
                      // the path the user took to arrive at a given page.
                      
                      // --------------------
                      // Modification by enidan
                      // Date: 2007.12.08
                      // Added &homePageId parameter
                      // Modif are indicated through /*OLD*/ and /*NEW*/ commments
                      // --------------------
                      
                      // Configuration Settings
                      
                          // $maxCrumbs [number]
                          // Max number of elements to have in a path.
                          // 100 is an arbitrary high number.
                          // If you make it smaller, like say 2, but you
                          // you are 5 levels deep, it will appear as:
                          // Home > ... > Level 4 > Level 5
                          // It should be noted that "Home" and the current
                          // page do not count. Each of these are configured
                          // separately.
                          (isset($maxCrumbs)) ? $maxCrumbs : $maxCrumbs = 100;
                      
                          // $pathThruUnPub [ 1 | 0 ]
                          // When your path includes an unpublished folder, setting this to 
                          // 1 will show all documents in path EXCEPT the unpublished.
                          // Example path (unpublished in caps)
                          // home > news > CURRENT > SPORTS > skiiing > article
                          // $pathThruUnPub = true would give you this:
                          // home > news > skiiing > article
                          // $pathThruUnPub = false  would give you this:
                          // home > skiiing > article (assuming you have home crumb turned on)
                          (isset($pathThruUnPub)) ? $pathThruUnPub : $pathThruUnPub = 1;
                         
                          // $respectHidemenu [ 1 | 0 ]
                          // Setting this to 1 will hide items in the breadcrumb list that
                          // are set to be hidden in menus.
                          (isset($respectHidemenu)) ? $respectHidemenu : $respectHidemenu = 1;
                      
                          // $showHomeCrumb [ 1 | 0 ]
                          // Would you like your crumb string to start
                          // with a link to home? Some would not because
                          // a home link is usually found in the site logo
                          // or elsewhere in the navigation scheme.
                          (isset($showHomeCrumb)) ? $showHomeCrumb : $showHomeCrumb = 1;
                      
                          // $showCrumbsAtHome [ 1 | 0 ]
                          // You can use this to turn off the breadcrumbs on the
                          // home page with 1.
                          // grad: actually '1' shows and '0' hides crumbs at homepage
                          (isset($showCrumbsAtHome)) ? $showCrumbsAtHome : $showCrumbsAtHome = 0;
                      
                          // $showCurrentCrumb [ 1 | 0 ]
                          // Show the current page in path with 1 or not with 0.
                          (isset($showCurrentCrumb)) ? $showCurrentCrumb : $showCurrentCrumb = 1;
                      
                          // $currentAsLink [ 1 | 0]
                          // If you want the current page crumb to be a
                          // link (to itself) then set to 1.
                          (isset($currentAsLink)) ? $currentAsLink : $currentAsLink = 0;
                      
                          // $crumbSeparator [string]
                          // Define what you want between the crumbs
                          (isset($crumbSeparator)) ? $crumbSeparator : $crumbSeparator = "»";
                      
                          // $homeCrumbTitle [string]
                          // Just in case you want to have a home link,
                          // but want to call it something else
                          (isset($homeCrumbTitle)) ? $homeCrumbTitle : $homeCrumbTitle = 'Home';
                      
                          // $homeCrumbDescription [string]
                          // In case you want to have a custom description of the home link
                          // Defaults to title of home link
                          (isset($homeCrumbDescription)) ? $homeCrumbDescription : $homeCrumbDescription = $homeCrumbTitle; 
                      
                          // $titleField [string]
                          // To change default page field to be used as
                          // a breadcrumb title, default is pagetitle
                          (isset($titleField)) ? $titleField : $titleField = 'pagetitle';
                      
                          // $descField [string]
                          // To change default page field to be used as
                          // a breadcrumb description, default is description (GA: falls back to pagetitle if description is empty)
                          (isset($descField)) ? $descField : $descField = 'description';
                      
                          /*NEW*/ // $homePageId [number]
                          /*NEW*/ // Define your home page ID, used for the home link
                          /*NEW*/ // Defaults to site_start
                          /*NEW*/ (isset($homePageId)) ? $homePageId : $homePageId = $modx->config['site_start'];
                      
                          // Included classes
                          // .B_crumbBox        Span that surrounds all crumb output
                          // .B_hideCrumb       Span surrounding the "..." if there are more crumbs than will be shown
                          // .B_currentCrumb    Span or A tag surrounding the current crumb
                          // .B_firstCrumb      Span that always surrounds the first crumb, whether it is "home" or not
                          // .B_lastCrumb       Span surrounding last crumb, whether it is the current page or not
                          // .B_crumb           Class given to each A tag surrounding the intermediate crumbs (not home, or hide)
                          // .B_homeCrumb       Class given to the home crumb
                          
                      
                      // ***********************************
                      // END CONFIG SETTINGS
                      // THE REST SHOULD TAKE CARE OF ITSELF
                      // ***********************************
                      
                      // Check for home page
                      /*OLD*/ //if ($showCrumbsAtHome || (!$showCrumbsAtHome && ($modx->documentIdentifier != $modx->config['site_start'])) ){
                      /*NEW*/ if ($showCrumbsAtHome || (!$showCrumbsAtHome && ($modx->documentIdentifier != $homePageId)) ){
                      
                          //initialize crumb array
                          $ptarr = array();
                          // get current page parent info
                          $docInfo = $modx->getDocument($modx->documentIdentifier,'id,pagetitle,menutitle,published,deleted,parent,hidemenu,description,longtitle,introtext');
                          $pid = $docInfo['parent'];
                          // show current page, as link or not
                          if ($showCurrentCrumb){
                              $titleToShow = ($docInfo[$titleField])? $docInfo[$titleField] : $docInfo['pagetitle'] ;
                              if ($currentAsLink && (!$respectHidemenu || ($respectHidemenu && $docInfo['hidemenu'] != 1 ))){
                                  $descriptionToUse = ($docInfo[$descField]) ? $docInfo[$descField] : $docInfo['pagetitle'] ;
                                  $ptarr[] = '<a class="B_currentCrumb" href="[~'.$modx->documentIdentifier.'~]" title="'.$descriptionToUse.'">'.$titleToShow.'</a>';
                              } else {
                                  $ptarr[] = '<span class="B_currentCrumb">'.$docInfo['pagetitle'].'</span>';
                              }
                          }
                          // assemble intermediate crumbs
                          $crumbCount = 0;
                          //$activeOnly = ($pathThruUnPub)? 0 : 1;
                          //while (($parent=$modx->getPageInfo($pid,$activeOnly,"id,pagetitle,menutitle,published,deleted,parent,hidemenu,description,longtitle,introtext")) && ($crumbCount < $maxCrumbs)) {
                          while (($parent=$modx->getPageInfo($pid,!$pathThruUnPub,"id,pagetitle,menutitle,published,deleted,parent,hidemenu,description,longtitle,introtext")) && ($crumbCount < $maxCrumbs)) {
                              /*OLD*/ //if ($parent['published'] && !$parent['deleted'] && $parent['id'] != $modx->config['site_start']){
                              /*NEW*/ if ($parent['published'] && !$parent['deleted'] && $parent['id'] != $homePageId){
                                  if (!$respectHidemenu || ($respectHidemenu && $parent['hidemenu'] != 1 )){
                                      $titleToShow = ($parent[$titleField])? $parent[$titleField] : $parent['pagetitle'] ;
                                      $descriptionToUse = ($parent[$descField]) ? $parent[$descField] : $parent['pagetitle'] ;
                                      $ptarr[] = '<a class="B_crumb" href="[~'.$parent['id'].'~]" title="'.$descriptionToUse.'">'.$titleToShow.'</a>';
                                  }
                              } // end if   
                              $pid = $parent['parent'];
                              $crumbCount++;
                          } // end while
                      
                          // insert '...' if maximum number of crumbs exceded
                          if ($parent != 0){
                              $ptarr[] = '<span class="B_hideCrumb">...</span>';
                          }
                      
                          // add home link if desired
                          /*OLD*/ //if ($showHomeCrumb && ($modx->documentIdentifier != $modx->config['site_start'])){
                          /*NEW*/ if ($showHomeCrumb && ($modx->documentIdentifier != $homePageId)){
                              /*OLD*/ //$ptarr[] = '<a class="B_homeCrumb" href="[~'.$modx->config['site_start'].'~]" title="'.$homeCrumbDescription.'">'.$homeCrumbTitle.'</a>';
                              /*NEW*/ $ptarr[] = '<a class="B_homeCrumb" href="[~'.$homePageId.'~]" title="'.$homeCrumbDescription.'">'.$homeCrumbTitle.'</a>';
                          }
                      
                          $ptarr = array_reverse($ptarr);
                          $ptarr[0] = '<span class="B_firstCrumb">'.$ptarr[0].'</span>';
                          $ptarr[count($ptarr)-1] = '<span class="B_lastCrumb">'.$ptarr[count($ptarr)-1].'</span>';
                          return '<span class="B_crumbBox">'. join($ptarr, " $crumbSeparator ").'</span>';
                      
                      }
                      ?>