Tridion 在内容交付中创建关键字列表

Tridion 在内容交付中创建关键字列表,tridion,tridion-2011,tridion-content-delivery,Tridion,Tridion 2011,Tridion Content Delivery,假设我有一个内容类型,它有两个类型为category的字段:一个是分类法作者,另一个是分类法主题,这两个分类法是不相关的,它们唯一的共同点是组件本身 现在我们以访问者的身份访问网站,然后当访问者单击给定的作者时,我想创建一个列表,列出包含特定作者的组件中的所有主题 我知道我可以创建一个查询对象,其中的条件包含来自不同分类法的两个关键字,以检查它是否检索到任何值,问题是我需要为每个主题(即作者和主题1、作者和主题2、作者和主题3等)执行该操作,最后,它可能意味着我不想做的数十个查询 在我看来,分类

假设我有一个内容类型,它有两个类型为category的字段:一个是分类法作者,另一个是分类法主题,这两个分类法是不相关的,它们唯一的共同点是组件本身

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

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


在我看来,分类API不会有什么帮助,因为分类法和它们前面的关键字是完全不相关的。有其他选择吗?

我认为您需要制定两个关键字标准

Criteria #1: Author = "Chris"

Criteria #2: Topic = "Topic1" or "Topic2" or "Topic3"
然后创建一个新的和标准,将两者结合起来

希望对您有所帮助,如果您需要一些示例,请指定您使用的是.NET还是Java


Chris

要创建查询对象,请借助组件。 在组件中,在单独的字段中添加以下类别: 主题(列表框,具有多个选择) 作者(下拉列表,单选…或根据需要)

在您的情况下,选择主题的所有列表框选项。 假设您有3个关键字,即主题1、主题2、主题3

因此,关键字将形成为:

KeywordCriteria topicCriteria1= new KeywordCriteria("Topic","Topic 1");
KeywordCriteria topicCriteria2= new KeywordCriteria("Topic","Topic 2");
KeywordCriteria topicCriteria3= new KeywordCriteria("Topic","Topic 3");

Criteria[] topicCriterias = {topicCriteria1,topicCriteria2,topicCriteria3};
Criteria OrCriteria = CriteriaFactory.Or(topicCriterias);


//Create Author Criteria
KeywordCriteria AuthorCriteria= new KeywordCriteria("Author","Author 1");

//And both results
mainCriteria =CriteriaFactory.And(AuthorCriteria, topicCriterias);

//Query
query.Criteria=mainCriteria;
要选择与主题相关的所有关键字,您可以编写一个方法,而不是单独编写。
希望这能有所帮助。

如果我正确理解您的需求,您可以使用
类别标准
关键字标准
的组合来实现这一点

CategoryCriteria
指定在本例中标记内容的类别
主题
KeywordCriteria
指定哪个类别的键值(例如:Author=Chris)

PublicationCriteria pubCriteria=新的PublicationCriteria(59);//出版范围
CategoryCriteria CategoryCriteria=新的CategoryCriteria(“主题”);
KeywordCriteria taxonomyKeywordCriteria=新的关键字标准(“作者”、“克里斯”);
Criteria allCriteria=CriteriaFactory.和(
新标准[]{pubCriteria,
和(新标准[]{categoryCriteria,taxonomyKeywordCriteria}})
);
Query allComps=新查询(allCriteria);
字符串[]compIDs=allComps.ExecuteQuery();
响应。写入(“
长度:“+compIDs.Length”);
那么您想查找所有标记有特定作者的组件,然后查找找到的组件的相应主题关键字关系

TaxonomyRelationManager应该能够在以下方面帮助您:

TaxonomyRelationManager manager = new TaxonomyRelationManager();
string[] contentWithThisAuthor = manager.GetTaxonomyContent(new Keyword(taxonomyUriOfAuthors, authorUri), false);
Keyword[] relatedTopics = manager.GetTaxonomyKeywords(taxonomyUriOfTopics, contentWithThisAuthor, new Keyword[] {}, null, 16);

基于Ram G的评论,因此以live content中的代码示例为起点,我已经验证了以下解决方案的有效性:

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...
                }
            }
        }
    }
}
使用系统;
使用系统集合;
使用系统配置;
使用系统数据;
使用System.Web;
使用System.Web.Security;
使用System.Web.UI;
使用System.Web.UI.HTMLControl;
使用System.Web.UI.WebControl;
使用System.Web.UI.WebControl.WebParts;
使用Tridion.ContentDelivery.taxonomy;
使用Tridion.ContentDelivery.DynamicContent.Query;
使用Tridion.ContentDelivery.DynamicContent;
命名空间Asier.Web.UI
{
公共类标记云:System.Web.UI.WebControls.WebControl
{
受保护的覆盖无效渲染(HtmlTextWriter编写器)
{
TaxonomyRelationManager relationManager=新的TaxonomyRelationManager();
TaxonomyFactory taxFactory=新的TaxonomyFactory();
字符串分类法yuriwhichi需要关键字from=“tcm:69-265-512”;
字符串[]componentUris=GetComponentUris();
字符串[]contextKeywordUris=GetKeywordUris();
关键字[]contextKeywordArray=GetKeywordsFromKeywordUris(taxFactory,contextKeywordUris);
关键字[]cloudFacets=relationManager.GetTaxonomyKeywords(TaxonomyUri,它需要来自、ComponentUri、contextKeywordArray、new CompositeFilter()、16的关键字);
关键词(云面);
}
私有静态字符串[]GetComponentUris()
{
//这可能应该替换为一个查询对象
//动态检索URI
返回新字符串[]{“tcm:69-3645-16”、“tcm:69-3648-16”、“tcm:69-3651-16”};
}
私有静态字符串[]GetKeywordUris()
{
//这可能应该作为控件的属性传入
返回新字符串[]{“tcm:69-3078-1024”};
}
私有静态关键字[]GetKeywordsFromKeywordURI(TaxonomyFactory taxFactory,字符串[]ContextKeywordURI)
{
关键字[]contextKeywordArray=新关键字[contextKeywordUris.Length];
for(int i=0;i0)
{
//做任何事。。。
}
}
}
}
}

谢谢你的回复,克里斯。我正在使用.NET。也许我没有正确地解释我自己,但老实说,我发现这个场景很难解释。您提供的示例允许我将所有组件分类为“Chris”和(“Topic1”或“Topic2”等),但这不是我需要做的。我需要得到这个