Retrieving related Component Presentations
Use the ComponentPresentationFactory method GetTaxonomyComponentPresentations to retrieve Component Presentations directly, based on a set of Keywords in a taxonomy. This method also requires a Template URI.
You can use this method to avoid 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 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);