Fork me on GitHub

Configuration

Class Name

The Breadcrumb plugin is implemented by the class:

org.onehippo.forge.breadcrumb.components.BreadcrumbComponent

Purpose

This class is used to create a Breadcrumb provider and set the breadcrumbs. The provider can be instantiated within a component to add breadcrumb functionalities by composition. It can be easily extended for specific, custom needs.

Component Parameters

Name Description
breadcrumb-separator A separator for the links that are displayed.
The default is right double angle quotes "»".
breadcrumb-menus The first part of the breadcrumb is generated from the expanded site menu items of the menu named 'main' or from multiple menu's as configured by this parameter. The last (trailing) part of the breadcrumb is generated from the resolved sitemap item belonging to the current request. The trailing items are based on the current resolved sitemap item and then moving upwards, until the highest menu item is encountered.
The default is "main".
breadcrumb-add-content-based Since 1.5.0
If 'true', and there is no active menu item to base the breadcrumb on, the breadcrumb is created from content, i.e. with items pointing to the current content bean and to upward content folders, if URLs exist for those.
The default is false.
breadcrumb-link-not-found-mode Since 2.0.0
Entries of the breadcrumb path may link to the pagenotfound sitemapitem, effectively giving a 404 if the user navigates to them. This parameter specifies alternative behaviour regarding rendering these items: if the value is "hide", the plugin will not render these entries at all. If the value is "unlink", the plugin will render the entries but without a link (so, as plain text).
The default is null, meaning no rendering behaviour change.

Rendering Attributes

Name Type Description
breadcrumb org.onehippo.forge.breadcrumb.om.Breadcrumb List with the breadcrumb items

Example of a template for the Breadcrumb

Create a Freemarker template such as the following example in the project's webfiles module, per default at repository-data/webfiles/src/main/resources/site/freemarker/myhippoproject/breadcrumb.ftl

<#include "../include/imports.ftl">

<#-- @ftlvariable name="breadcrumb" type="org.onehippo.forge.breadcrumb.om.Breadcrumb" -->
<#if breadcrumb?? && breadcrumb.items??>
    <#list breadcrumb.items as item>
        <#if item.link.notFound && (breadcrumb.linkNotFoundMode == 'hide' || breadcrumb.linkNotFoundMode == 'unlink')>
            <#if breadcrumb.linkNotFoundMode == 'unlink'>
                <a>${item.title?html}</a><#sep> ${breadcrumb.separator}&nbsp;
            </#if>
        <#else>
            <@hst.link var="link" link=item.link/>
            <a <#sep>href="${link}"</#sep>>${item.title?html}</a><#sep> ${breadcrumb.separator}&nbsp;
        </#if>
    </#list>
</#if>

HST Configuration

  1. In the console, add node breadcrumb.template to /hst:hst/hst:configurations/myhippoproject/hst:templates as defined in the YAML below and have it auto-exported.

    Alternatively, append the following piece of YAML to the existing repository-data/application/src/main/resources/hcm-config/hst/configurations/myhippoproject/templates.yaml file:

    /breadcrumb.template:
      jcr:primaryType: hst:template
      hst:renderpath: webfile:/freemarker/myhippoproject/breadcrumb.ftl
    
  2. In the console, add node breadcrumb to /hst:hst/hst:configurations/myhippoproject/hst:components as defined in the YAML below and have it auto-exported.

    Alternatively, create breadcrumb.yaml in repository-data/application/src/main/resources/hcm-config/hst/configurations/myhippoproject/components/:

    definitions:
      config:
        /hst:hst/hst:configurations/myhippoproject/hst:components/breadcrumb:
          jcr:primaryType: hst:component
          hst:componentclassname: org.onehippo.forge.breadcrumb.components.BreadcrumbComponent
          hst:template: breadcrumb.template

Applying breadcrumb to pages

To apply the breadcrumb to pages in the website, use the standard method, see HST Component Configuration page.

For example, to apply the breadcrumb to all pages, add node breadcrumb to /hst:hst/hst:configurations/myhippoproject/hst:abstractpages/base. Auto-export should insert a piece of yaml that looks like this:

/breadcrumb:
  jcr:primaryType: hst:component
  hst:referencecomponent: hst:components/breadcrumb

Then, to relevant Freemarker template base-layout.ftl, add the following reference: <@hst.include ref="breadcrumb"/>