在Content Delivery中创建关键字列表

Asi*_*dez 11 tridion tridion-content-delivery tridion-2011

想象一下,我有一个内容类型,它有两个类型类别的字段:一个是分类法作者,另一个是分类法主题,这两个分类法是无关的,它们可能有的唯一共同点是组件本身.

现在我们以访问者的身份访问网站,然后当访问者点击给定的作者时,我想创建一个列表,其中包含组件中存在的所有主题,这些主题也包含特定的作者.

我知道我可以创建一个查询对象,其中包含来自不同分类的两个关键字的标准,以检查它是否检索到任何值,问题是我需要为每个主题执行此操作,即作者和主题1,作者和主题2,作者和主题3等,最后它可能意味着数十个查询,我显然不想这样做.

正如我所看到的那样,分类法API无济于事,因为分类法和它们的关键词完全不相关.任何替代品?

Asi*_*dez 2

根据 Ram G 的评论,并以实时内容中的代码示例为起点,我已经验证了以下解决方案的工作原理:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Tridion.ContentDelivery.Taxonomies;
using Tridion.ContentDelivery.DynamicContent.Query;
using Tridion.ContentDelivery.DynamicContent;

namespace Asier.Web.UI
{
    public class TagCloud : System.Web.UI.WebControls.WebControl
    {
        protected override void Render(HtmlTextWriter writer)
        {
            TaxonomyRelationManager relationManager = new TaxonomyRelationManager();
            TaxonomyFactory taxFactory = new TaxonomyFactory();

            string taxonomyUriWhichIWantTheKeywordsFrom = "tcm:69-265-512";

            String[] componentUris = GetComponentUris();
            String[] contextKeywordUris = GetKeywordUris();
            Keyword[] contextKeywordArray = GetKeywordsFromKeywordUris(taxFactory, contextKeywordUris);
            Keyword[] cloudFacets = relationManager.GetTaxonomyKeywords(taxonomyUriWhichIWantTheKeywordsFrom, componentUris, contextKeywordArray, new CompositeFilter(), 16);

            ProcessKeywords(cloudFacets);
        }

        private static string[] GetComponentUris()
        {
            // This should probably be replaced with a Query object that
            // retrieves the URIs dynamically 
            return new String[] { "tcm:69-3645-16", "tcm:69-3648-16", "tcm:69-3651-16" };
        }

        private static string[] GetKeywordUris()
        {
            // this should probably be passed in as a property of the control
            return new string[] { "tcm:69-3078-1024" };
        }

        private static Keyword[] GetKeywordsFromKeywordUris(TaxonomyFactory taxFactory, String[] contextKeywordUris)
        {
            Keyword[] contextKeywordArray = new Keyword[contextKeywordUris.Length];

            for (int i = 0; i < contextKeywordUris.Length; i++)
            {
                contextKeywordArray[i] = taxFactory.GetTaxonomyKeyword(contextKeywordUris[i]);
            }

            return contextKeywordArray;
        }        

        private static void ProcessKeywords(Keyword[] cloudFacets)
        {
            for (int i = 0; i < cloudFacets.GetLength(0); i++)
            {

                if (cloudFacets[i].ReferencedContentCount > 0)
                {
                    // Do whatever...
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)