On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Breadcrumb is a snippet for MODx Revolution, inspired by the jaredc/splittingred's BreadCrumbs snippet.

    As the original jaredc/splittingred's BreadCrumbs, this snippet will create a breadcrumb navigation (no kidding laugh). That's not all ! I also added several new feature that I really needed like template properties or specific resource ID property.

    Documentation : http://rtfm.modx.com/display/ADDON/BreadCrumb
    Package : http://modx.com/extras/package/breadcrumb
    Github : https://github.com/omycode/breadcrumb

    Usage
    // Show the breadcrumb of the current resource
    [[BreadCrumb]]
    
    // Show the breadcrumb of the resource whose ID is 72
    [[BreadCrumb? &to=`72`]]
    
    // Show the breadcrumb of the resource whose ID is 72 from it's level 2 parent
    [[BreadCrumb? &from=`[[UltimateParent? &topLevel=`2`]]` &to=`72`]]
    
    // Change the direction of the breadcrumb : rtl (Right To Left) or ltr (Left To Right)
    [[BreadCrumb? &direction=`rtl`]]
    
    // Use custom templates
    [[BreadCrumb? &linkCrumbTpl=`myLinkCrumbTpl`]]
    


    This snippet support most of jaredc/splittingred's BreadCrumbs features :

    - maxCrumbs
    - pathThruUnPub (now as showUnPub)
    - respectHidden (now as showHidden)
    - showCrumbsAtHome
    - showCurrentCrumb
    - showHomeCrumb

    And add new features that I really needed :

    - chunk as templates (properties &containerTpl, ¤tCrumbTpl, &linkCrumbTpl, &maxCrumbTpl)
    - breadcrumb for and from specific resource (property &from and &to)
    - direction (property &direction)
    - showContainer property

    Some properties of jaredc/splittingred's BreadCrumbs have been removed but can easily be replaced by chunk / CSS customization, as :

    - crumbSeparator
    - currentAsLink
    - descField
    - homeCrumbDescription
    - homeCrumbTitle
    - maxDelimiter
    - titleField
    [ed. note: ben_omycode last edited this post 7 years, 3 months ago.]
    • Great to see new features for breadcrumbs, keep up the good work. Especially like the RTL support.

      One question: is there a way to change <li> css style for home crumb when displayed alone? At the moment it has B_firstCrumb (with breadcrumbs), but it should also be B_lastCrumb when used with no current crumb displayed. I use special formatting for all last crumbs (in this case home). Thanks!
      • Hi encho,

        You can use the showHomeCrumb property. It will create a crumb for the home page. If the home crumb displayed alone so that means it's the current one (and so the last one).
        [[BreadCrumb? &showHomeCrumb=`1`]]

        You can next apply your CSS style to .current class element.

        (You also can use the :last-child CSS selector but IE8 and < don't support it.)
        • Thanks for your answer, but it still does not display css properly. My code is:
          [[Breadcrumb? &crumbSeparator=`` &showHomeCrumb=`1` &showCurrentCrumb=`0` &currentAsLink=`0` &respectHidemenu=`0`]]

          And when the menu is 2 levels deep it shows something like Home - About Us > (Page title and content), not showing the page title as part of a breadcrumb (I prefer that way) and 'About Us' will have 'last' css property. But when you are 1 level deep - ie. when you are on 'About Us' page, the breadcrumb should only show 'Home' and it does: Home > but the css for 'Home' only shows 'first'.

          I hope that explains it so when Home is alone it should have 'first' AND 'last'. Thanks!
          • Are you sur you're using my BreadCrumb snippet and not the popular Breadcrumbs snippet by splittingred ?

            My snippet don't support the next properies because they can be replaced by chunk / CSS customization :
            - crumbSeparator
            - currentAsLink
            - descField
            - homeCrumbDescription
            - homeCrumbTitle
            - maxDelimiter
            - titleField
            • Sorry, copied wrong code, here is the original:

              [[Breadcrumb? &showHomeCrumb=`1` &showCurrentCrumb=`0` &showHidden=`1`]]
              


              Still do not understand how to get Home crumb display both 'first' and 'last'. I have another workaround if that doesn't work, just puzzled with this.
              • BreadCrumb don't dynamically add classes to crumbs. I don't understand how you can have a "first" class append to your home crumb.

                Can you post your breadcrumb chunks please ?
                • Did it manually in BreadCrumbContainerTpl
                  <ul id="breadcrumb" itemprop="breadcrumb">
                    <li><a href="[[++site_url]]"><a class="first">Home</a></li>
                    [[+crumbs]]
                  </ul>

                  It would be even better if I used li instead of a, but not sure how. And not sure if possible at all to make some kind of condition if the link is alone in the crumb. But as I said before, I will try to have some kind of a workaround. Thanks.
                  • You can test if the placeholder crumbs is empty :
                    <ul id="breadcrumb" itemprop="breadcrumb">
                    	<li class="first [[+crumbs:isempty=`last`:isnotempty=``]]"><a href="[[++site_url]]">Home</a></li>
                    	[[+crumbs]]
                    </ul>

                    • Doesn't show 'last' unfortunately. I will use css tricks to get what I want, no point in wasting your time anymore. Thanks for all your help.