使用Taxonomy关键字创建Tridion标签云?

时间:2012-10-31 11:49:12

标签: tridion tridion-2011 tridion-content-delivery

CMS中的内容使用关键字进行标记,发布后将其用作跟踪关键字,每次加载页面时,该值都会递增。过去,DB Query与Tridion Broker DB一起用于生成标签云。我想改变它并改为使用Tridion Broker API。

Tridion在线文档有nice example(首先登录http://sdllivecontent.sdl.com/)。该示例显示了如何使用API​​获取关键字的计数。

我希望有一个聚合查询,而不是一次获取count 1关键字。是否可以使用Broker API或使用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 + ", ");
}

1 个答案:

答案 0 :(得分:4)

不要认为使用BrokerQuery API可以实现所需。但是,您可以使用Taxonomy API获取完整的分类,并查看该分类中每个关键字的ReferencedContentCount。

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
}

希望这有帮助。

干杯, 丹尼尔。