Retrieving related Component Presentations
The ComponentPresentationFactory has a method to retrieve Component Presentations directly based on a number of Keywords in a taxonomy without having to first call the TaxonomyRelationManager. The API operation is similar to the one in the TaxonomyRelationManager, with the difference that you need to pass the templateURI and not the item type of the desired content items. The return type of the operation is a Component Presentation array.
The following code demonstrates how to retrieve Component Presentations directly using the ComponentPresentationFactory:
String[] selectedKeywordURIs = new String[] { "tcm:12-800-1024", "tcm:12-801-1024", "tcm:12-856-1024" };
Keyword[] selectedKeywords = new Keyword[selectedKeywordURIs.Length];
TaxonomyFactory taxonomyFactory = new TaxonomyFactory();
for (int i = 0; i < selectedKeywordURIs.Length; i++)
{
selectedKeywords[i] = taxonomyFactory.GetTaxonomyKeyword(selectedKeywordURIs[i]);
}
ComponentPresentationFactory presentationfactory = new ComponentPresentationFactory(12);
ComponentPresentation[] componentPresentations =
presentationfactory.GetTaxonomyComponentPresentations(selectedKeywords, "tcm:12-234-32", true);