We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29988
    • 89 Posts
    My suggestion is to add one or two classes, to ensure correct behaviour, when the line is too long and we don’t have the space.

    It still does not solve the problem when the titles of breadcrump folder are long, but at least it’s ok when the folders’ titles are quite short but the site title is long.

    Solved example: http://www.dotprofit.cz/proc-muze-byt-optimalizace-pro-vyhledavace-slozitejsi-nez-si-myslite

    <?php
    // --------------------
    // Snippet: Breadcrumbs
    // --------------------
    // Version: 0.91
    // Date: 2006.03.29
    // [email protected]
    // Honorable mentions:
    // - Bill Wilson
    // - [email protected]
    //
    // 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.
    
    // Changes by grad (http://modxcms.com/forums/index.php?action=profile;u=1841;sa=summary):
    // 1) redefinition of default values; the snippet call with parameters from within a chunk didn't work
    // 2) added 'longtitle' and 'introtext' to pool of available titles and descriptions
    // 3) added $homeCrumbDescription - a custom home link description
    
    // 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 you 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 = 0;
    
       // $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';
    
    	// mod by grad
    	// $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';
    
    // ***********************************
    // END CONFIG SETTINGS
    // THE REST SHOULD TAKE CARE OF ITSELF
    // ***********************************
    
    // Check for home page
    if ($showCrumbsAtHome || (!$showCrumbsAtHome && ($modx->documentIdentifier != $modx->config['site_start'])) ){
    
      //initialize crumb array
      $ptarr = array();
      // get current page parent id;
      // mod by grad: added 'longtitle' and 'introtext'
      $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="breadcrumpitem" href="[~'.$modx->documentIdentifier.'~]" title="'.$descriptionToUse.'">'.$titleToShow.'</a>';
        } else {
          $ptarr[] = '<span class="breadcrumpitem-last">'.$docInfo['pagetitle']."</span>";
        }
      }
        // assemble intermediate crumbs
        $crumbCount = 0;
        $activeOnly = ($pathThruUnPub)? 0 : 1;
        // mod by grad: added 'longtitle' and 'introtext'
    	 while (($parent=$modx->getPageInfo($pid,$activeOnly,"id,pagetitle,menutitle,published,deleted,parent,hidemenu,description,longtitle,introtext")) && ($crumbCount < $maxCrumbs)) {
            if ($parent['published'] && !$parent['deleted'] && $parent['id'] != $modx->config['site_start']){
                if (!$respectHidemenu || ($respectHidemenu && $parent['hidemenu'] != 1 )){
                    $titleToShow = ($parent[$titleField])? $parent[$titleField] : $parent['pagetitle'] ;
    	              $descriptionToUse = ($parent[$descField]) ? $parent[$descField] : $parent['pagetitle'] ;
                    $ptarr[] = '<a class="breadcrumpitem" 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[] = '...';
        }
    
        // add home link if desired
        if ($showHomeCrumb && ($modx->documentIdentifier != $modx->config['site_start'])){
            // mod by grad: added $homeCrumbDescription
    		  $ptarr[] = '<a class="breadcrumpitem" href="[~'.$modx->config['site_start'].'~]" title="'.$homeCrumbDescription.'">'.$homeCrumbTitle.'</a>';
        }
    
        $ptarr = array_reverse($ptarr);
        return join($ptarr, "<span class=\"breadcrumpitem\"> $crumbSeparator </span>");
    
    } // end check if home page
    ?>

      • 6726
      • 7,075 Posts
      Nice upgrade Tillda I’ll make sure to check this out, I have a few site using this snippet it might make them better smiley
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l&#39;outil id