Reputation: 2727
Content in the CMS is tagged with Keywords and after publishing they are used as Tracking Keys and the value is incremented each time a Page is loaded. In the past a DB Query was used with the Tridion Broker DB to produce a tag cloud. I would like to change this and use the Tridion Broker API instead.
The Tridion Online Documentation has a nice example (login to http://sdllivecontent.sdl.com/ first). The example shows how to get the count of a keyword using the API.
I would like to have an aggregate query instead of getting the count 1 keyword at a time. Is it possible with the Broker API or using 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 + ", ");
}
Upvotes: 4
Views: 451
Reputation: 1711
Don't think you can achieve what you need by using the BrokerQuery API. You can, however, use the Taxonomy API to get a full taxonomy and to look at the ReferencedContentCount 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.
Upvotes: 4