Create a Tridion Tag Cloud with Taxonomy Keywords?

The content in the CMS is marked with keywords, and after publication, they are used as tracking keys, and the value increases each time the page loads. In the past, Query DB was used with Tridion Broker DB to create a tag cloud. I would like to change this and use the Tridion Broker API.

The Tridion Online documentation has a good example (login to http://sdllivecontent.sdl.com/ first). This example shows how to get the keyword counter using the API.

I would like to have an aggregate query instead of getting the keyword count 1 at a time. Is this possible with the Broker API or with the Ambient Framework?

string strTaxURI = "tcm:34-70-512", strTaxKeywordURI = "tcm:34-549-1024"; Query myQuery = new Query(); Criteria myCriteria = null; TaxonomyKeywordCriteria taxonomyKeywordCriteria = new TaxonomyKeywordCriteria(strTaxURI, strTaxKeywordURI, false); myCriteria = taxonomyKeywordCriteria; myQuery.Criteria = myCriteria; // filter code limiting results commented out.... string[] itemURIs = myQuery.ExecuteQuery(); foreach (string itemURI in itemURIs) { Response.Write(itemURI + ", "); } 
+4
source share
1 answer

Do not think that you can achieve what you need using the BrokerQuery API. However, you can use the Taxonomy API to get the full taxonomy and see the linkContentCount of each keyword in that taxonomy.

 TaxonomyFactory taxonomyFactory = new TaxonomyFactory(); Tridion.ContentDelivery.Taxonomies.Keyword category = taxonomyFactory.GetTaxonomyKeywords("tcm:9-3-512"); Response.Write(category.ReferencedContentCount); if (category.HasChildren) { // get the category.KeywordChildren and loop over them } 

Hope this helps.

Cheers, Daniel.

+4
source

Source: https://habr.com/ru/post/1443213/


All Articles