This article covers a Bloomreach Experience Manager version 11. There's an updated version available that covers our most recent release.

Taxonomy Plugin Extra Taxonomy Field in Document Type

Add an extra taxonomy picker to a document type

In order to add an extra, second taxonomy picker to a document type, the following steps have to be taken:

  • Configure a second taxonomy DAO service with a differently configured  MixinClassificationDaoPlugin
  • Add an additional plugin context to your template that uses that service

Add a second taxonomy DAO service using the MixinClassificationDaoPlugin

The class  org.onehippo.taxonomy.plugin.MixinClassificationDaoPlugin has a configuration property fieldPath. The value of that property is the name of the property where the additional taxonomy keys are stored.
For document types using the service  service.taxonomy.dao.alternate in their template, the alternate taxonomy keys will be stored in a property called taxonomydemo:alternatekeys.

<?xml version="1.0" encoding="UTF-8"?>
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="alternateClassificationDaoService">
  <sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>frontend:plugin</sv:value>
  </sv:property>
  <sv:property sv:name="fieldPath" sv:type="String">
    <sv:value>taxonomydemo:alternatekeys</sv:value>
  </sv:property>
  <sv:property sv:name="plugin.class" sv:type="String">
    <sv:value>org.onehippo.taxonomy.plugin.MixinClassificationDaoPlugin</sv:value>
  </sv:property>
  <sv:property sv:name="taxonomy.classification.dao" sv:type="String">
    <sv:value>service.taxonomy.dao.alternate</sv:value>
  </sv:property>
</sv:node>

Additional taxonomy fields need to be configured through the CMS Console.

To add the service to your configuration:

  • In the Console, go to /hippo:configuration/hippo:frontend/cms/cms-services.
  • Create a structure like above, perhaps by copying the existing classificationDaoService and add property fieldPath with the wanted property name.
  • Write changes to repository.

Make sure that this change is recorded in your project's bootstrap resource, such that it will become available in other environments as well!

Add an additional plugin context to your template that uses that service

The following description is based on a document type doubletaxonomy with one taxonomy. The namespaceprefix of the project is taxonomydemo. While the document type still has a single taxonomy field only, its editor templates structure looks like:

To add an extra taxonomy field, add the following configuration to the editor:templates/_default_ node

<?xml version="1.0" encoding="UTF-8"?>
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="extrataxonomy">
  <sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>frontend:plugin</sv:value>
  </sv:property>
  <sv:property sv:name="plugin.class" sv:type="String">
    <sv:value>org.onehippo.taxonomy.plugin.TaxonomyPickerPlugin</sv:value>
  </sv:property>
  <sv:property sv:name="taxonomy.classification.dao" sv:type="String">
    <sv:value>service.taxonomy.dao.alternate</sv:value>
  </sv:property>
  <sv:property sv:name="taxonomy.id" sv:type="String">
    <sv:value>service.taxonomy</sv:value>
  </sv:property>
  <sv:property sv:name="taxonomy.name" sv:type="String">
    <sv:value>exampletaxonomy</sv:value>
  </sv:property>
  <sv:property sv:name="wicket.id" sv:type="String">
    <sv:value>${cluster.id}.left.item</sv:value>
  </sv:property>
  <sv:property sv:name="field" sv:type="String"> 
    <sv:value>extrataxonomy</sv:value> 
  </sv:property>
</sv:node>

Next add the following configuration to the hipposysedit:nodetype/hipposysedit:nodetype node

<?xml version="1.0" encoding="UTF-8"?> 
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="extrataxonomy">
  <sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>hipposysedit:field</sv:value>
  </sv:property>
  <sv:property sv:name="hipposysedit:multiple" sv:type="Boolean">
    <sv:value>true</sv:value>
  </sv:property>
  <sv:property sv:name="hipposysedit:path" sv:type="String">
    <sv:value>taxonomydemo:alternatekeys</sv:value>
  </sv:property>
  <sv:property sv:name="hipposysedit:type" sv:type="String">
    <sv:value>String</sv:value>
  </sv:property>
</sv:node>

The following properties should be set to match your requirements:

Property name Description
taxonomy.classification.dao The name of the DAO service that is used.
taxonomy.name The name of the taxonomy to use.
wicket.id The layout part where the additional taxonomy will be placed (e.g. '${cluster.id}.left.item' for left column)

To add the template plugin to your document type:

  • In the Console, import the above xml (the edited frontend:plugin) at /hippo:namespaces/[yournamespace]/[yourdocumenttype]/editor:templates/_default_
  • Write changes to repository
  • To view the changes in the cms log in again, the services will be reloaded

Again, make sure that this change is recorded in your project's bootstrap resource, such that it will become available in other environments as well.

Labels for the classifiable and extrataxonomy fields can be provided by adding configuration under /hippo:configuration/hippo:translations/hippo:types/[yourdocumenttype]/ as explained in internationalization of field captions.

As of Taxonomy Plugin 3.0.1 the label for the extrataxonomy field is matched by the value of the hipposysedit:path property configured at /hippo:namespaces/[yournamespace]/[yourdocumenttype]/hipposysedit:nodetype/hipposysedit:nodetype/extrataxonomy

Your document type should now look like this:

Wrapping up 

Test your configuration:

  • Create a new document of the adjusted document type
  • Select taxonomy items for each taxonomy picker
  • Save the document
  • In the console, make sure all the taxonomy keys are stored in the right location. The following query should return all documents that have both properties: //element(*,taxonomydemo:doubletaxonomy)/[@hippotaxonomy:keys and @taxonomydemo:alternatekeys]

Existing documents do not yet have the new property, nor has it been added to the prototype. hippotaxonomy:classifiable can be added to your document type in the CND. The new property has not been defined by a mixin.

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?