This article covers a Bloomreach Experience Manager version 12. 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.

/alternateClassificationDaoService:
  jcr:primaryType: frontend:plugin
  fieldPath: taxonomydemo:alternatekeys
  plugin.class: org.onehippo.taxonomy.plugin.MixinClassificationDaoPlugin
  taxonomy.classification.dao: service.taxonomy.dao.alternate

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

/extrataxonomy:
  jcr:primaryType: frontend:plugin
  plugin.class: org.onehippo.taxonomy.plugin.TaxonomyPickerPlugin
  taxonomy.classification.dao: service.taxonomy.dao.alternate
  taxonomy.id: service.taxonomy
  taxonomy.name: exampletaxonomy
  wicket.id: ${cluster.id}.left.item
  field: extrataxonomy

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

/extrataxonomy:
  jcr:primaryType: hipposysedit:field
  hipposysedit:multiple: true
  hipposysedit:path: taxonomydemo:alternatekeys
  hipposysedit:type: String

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?