Skipping Directories in Breadcrumbs

Aaron Smith's Avatar

Aaron Smith

17 Aug, 2016 08:51 PM

I have breadcrumbs on my site, but I need to skip the link for the first page after the "Home" link. How do I identify that page to remove it from the breadcrumbs?

Here's my code:
#macro (displayCrumbs $crumb $lastPage $lastFolder)
    #set ($isFolder = ($crumb.identifer.type == $_FieldTool.in("com.hannonhill.cascade.model.dom.identifier.EntityTypes").TYPE_FOLDER))
    
    #if ($lastPage.name == "index" && $lastFolder == $crumb)
        <span>${_EscapeTool.xml($crumb.metadata.displayName)}</span>
    #elseif ($crumb == $currentPage && $crumb.name != "index")
        <span>${_EscapeTool.xml($crumb.metadata.displayName)}</span>
    #elseif ($crumb.name == "/")
        ## Skip here, we are always including the home before we build the breadcrumbs
        ## <a href="$crumb.link/index">Home</a>
    #elseif ($isFolder)
        <a href="$crumb.link/index">${_EscapeTool.xml($crumb.metadata.displayName)}</a>
    #elseif ($crumb.name != "index")
        <a href="$crumb.link">${_EscapeTool.xml($crumb.metadata.displayName)}</a>
    #else
    #end
#end

Thanks!
Aaron

Comments are closed, but you can start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac