Taxonomy Plugin Delivery Tier Configuration

Configure and use the Taxonomy Plugin in the delivery tier (HST).

TaxonomyManager and Beans Annotated Classes

After adding and configuring the Taxonomy plugin using the setup application, a Spring TaxonomyManager component is available out-of-the-box. 

Make sure the hst-beans-annotated-classes context parameter is defined in src/main/webapp/WEB-INF/web.xml in your project's site module (if you created your project from the archetype, it should already be there):


Render a Document's Categories

Content Bean

After you add taxonomy to a document type using the Essentials setup application, make sure to run the Beanwriter tool to update the document type's content bean class. This will add a getKeys() method to the bean class:

    public String[] getKeys() {
        return getMultipleProperty("hippotaxonomy:keys");

JSP Template

The Taxonomy Plugin includes a tag library (TLD) containing a single tag (TaxonomyTag) to help render a document's categories.

Declare the taxonomy tag library:

<%@ taglib uri="" prefix='tax'%>

Use the tax:categories tag to obtain a list of lists of org.onehippo.taxonomy.api.Category objects, then iterate through the nested lists and render each category for the document's locale:

<tax:categories var="list" keys="${document.keys}" />
<c:forEach var="ancestors" items="${list}">
    <c:forEach var="category" items="${ancestors}">
      <c:set var="categoryInfo" value="${category.infos[document.locale]}" />

Freemarker Template

Currently, due to HIPPLUG-1409, Freemarker support is limited. Your best option is to obtain all required taxonomy information within an HST component (see below) and use request attributes to make that information available to the Freemarker template.

Obtain a Taxonomy within an HST Component

Import the required classes, obtain the TaxonomyManager, then obtain a taxonomy by the name of its root node (exampletaxonomy in this example):

import org.onehippo.taxonomy.api.Taxonomy;
import org.onehippo.taxonomy.api.TaxonomyManager;

final TaxonomyManager taxonomyManager =
  HstServices.getComponentManager().getComponent(TaxonomyManager.class.getSimpleName(), "org.onehippo.taxonomy.contentbean");
Taxonomy taxonomy = taxonomyManager.getTaxonomies().getTaxonomy("exampletaxonomy");

The Taxonomy Essentials demo feature shows several ways to use a Taxonomy object from within the delivery tier: to search for a taxonomy value, to generate the full taxonomy tree and to locate an entry.

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?