Displaying related content based on content context

The Taxonomy API provides a way of filtering of a taxonomy based on the found Keywords related to the content context. This enables the retrieval of parent/children of found Keywords and allows you to implementations of content context driving filtering of taxonomies such as breadcrumb trails (retrieve all Keywords to the start of the taxonomy), tags clouds (of all related Keywords)

In a list of Keywords, the number of related Components is displayed in brackets next to each Keyword. You can use the Taxonomies API to filter Keywords based on content context so that when you select one or more Keywords in the navigation, the Keyword counts displayed in brackets is updated to reflect the number of Components that are related to the selected Keywords ("context aware Keyword counts"):

  • You can retrieve Keywords directly related to a Component Presentation or Page, specify filter direction up and down taxonomy hierarchy, and use URL, URI or other valid identifiers.
  • You can retrieve a Keyword branch related to a Component Presentation or Page and specify the direction to filter content (up and down taxonomy hierarchy) and the depth (number of levels).

The following code demonstrates the basic API call:

CompositeFilter emptyFilter = new CompositeFilter();
String[] selectedKeywords = new Keyword[] {};
String[] componentURIS = new String[] { "tcm:12-40-16", "tcm:12-41-16", "tcm:12-42-16" };
TaxonomyRelationManager relationManager = new TaxonomyRelationManager();
Keyword[] keywords = relationManager.GetTaxonomyKeywords ("tcm:12-900-512", componentURIS, selectedKeywords, emptyFilter, 16);

where GetTaxonomyKeywords takes the following parameters:

  • TCM URI of a taxonomy (Category)
  • componentURIS is the list of Components you want to retrieve related Keywords for
  • selectedKeywords contains the selected Keywords
  • emptyFilter specifies that only the directly related Keywords are retrieved (the filter applied is empty)
  • 16 os the item type for related Keywords that must be retrieved (Components)