Taxonomy Plugin Required Taxonomy Field - Bloomreach Experience - Open Source CMS

This article covers a Hippo CMS version 10. There's an updated version available that covers our most recent release.


Taxonomy Plugin Required Taxonomy Field

Set a taxonomy field to be required 

This feature is supported since Taxonomy Plugin version 1.11.03 for Hippo 7.9.

In order to make a taxonomy field required, meaning that at least one category must be applied to a document, the following steps have to be taken:

  1. Configure the  org.onehippo.taxonomy.plugin.TaxonomyPickerPlugin frontend plugin
  2. Set required validator on classifiable mixin or document type field

1. Configure the TaxonomyPickerPlugin as frontend plugin 

Although the standard way to configure a taxonomy field is to have a classifiable node with a  org.hippoecm.frontend.editor.plugins.mixin.MixinLoaderPlugin below the editor:templates part of your document type, using this setup will only give a feedback message and will  not show an invalidated field using red coloring.

To produce the correct validation highlighting, we need to configure the TaxonomyPickerPlugin directly, for a field called 'taxonomy':
('+' is node, '-' is property)

+ /hippo:namespaces/yournamespace/yourdocumenttype/editor/templates/_default_/taxonomy
  - jcr:primaryType=frontend:plugin
  - field=taxonomy   (optional, defaults to 'keys')
  - plugin.class=org.onehippo.taxonomy.plugin.TaxonomyPickerPlugin
  - taxonomy.classification.dao=service.taxonomy.dao
  -${}.field   (or applicable layout part e.g. ${}.right.item)

2. Set 'required' validator on classifiable mixin or document type field 

Now, we need to set a required validator on the taxonomy field. We can do this on the mixin level or on the document type level.

2a. Set classifiable mixin as 'required' 

Setting the mixin hippotaxonomy:classifiable as required will make the taxonomy fields in every document type required. To do that, add a validator required here:

+ /hippo:namespaces/hippotaxonomy/classifiable/hipposysedit:nodetype/hipposysedit:nodetype/keys
  - hipposysedit:validators='required'   (String, multiple)

2b. Add a field with validator 'required' to the document type 

For setting the taxonomy field as required on document type level, please add a field node below the hipposysedit:nodetype part of the type, also with a validator required. It either must be named keys or it must be linked to in the frontend plugin using field=[name], see above in  section 1..

+ /hippo:namespaces/yournamespace/yourdocumenttype/hipposysedit:nodetype/hipposysedit:nodetype/keys
  - jcr:primaryType=hipposysedit:field
  - hipposysedit:multiple=true  (Boolean)
  - hipposysedit:path='hippotaxonomy:keys'  (String)
  - hipposysedit:type='String'  (String)
  - hipposysedit:validators='required'  (String, multiple)

The result 

See this screenshot from the demo project on how a required field will look in the CMS:

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?