Taxonomy Plugin Configuration
Installation
The Taxonomy plugin can be added to your project using the setup application.
Prerequisites:
- Bloomreach Experience Manager project with the Essentials setup application.
Instructions:
- Using Essentials, add Taxonomy to your project.
- Rebuild and restart your project.
Configuration
- In Essentials, navigate to Installed features.
- Find Taxonomy and click on the Configure button.
- To create a new, empty taxonomy, enter a name and choose the locales to include.
- Click on the Create new taxonomy button.
- Select the document types to add taxonomy to, and choose the taxonomy to use.
- Click on the Add taxonomy to documents button.
- Use the BeanWriter tool to regenerate the content bean(s) for the document type(s) you added taxonomy to.
The taxonomy can now be managed in the CMS Content perspective in the newly added Taxonomies section.
When editing documents that use a taxonomy, you can select categories from the taxonomy dialog.
Optional: Write and Configure a Category Filter
If you have a use case where you want to hide categories in certain circumstances, e.g. based on the current user or some data on the category node, you can create an implementation of the JcrCategoryFilter in your CMS.
Please note that hiding categories for users A while showing them for users B may result in documents with category values on them that are unknown to the users A, resulting in "Invalid category key" in the taxonomy picker. The use case design has to solve that.
import org.onehippo.taxonomy.plugin.api.JcrCategoryFilter; /** * Category filter that hides categories if it doesn't have a certain property. */ public class MyCategoryFilter implements JcrCategoryFilter { @Override public boolean apply(final JcrCategory category, final HippoSession session) { // hide for author if (session.getUser().getId().equals("author")) { return false; } // hide based on absent property if (!category.getJcrNode().hasProperty("myproject:authorized")) { return false; } // OK return true; } }
There is also a (non-configured) filter in the demo project: HideForAuthorCategoryFilter.java
Such a filter can be configured by means of the following taxonomy service property:
/hippo:configuration/hippo:frontend/cms/cms-services/taxonomyService: taxonomy.category.filters: com.myproject.cms.taxonomy.MyCategoryFilter
Multiple filter classes can be specificied as a comma-separated string.