简体   繁体   English

如何在Ektron中选择属于分类法的库项目

[英]How to select library items that belong to a taxonomy in Ektron

I'm using Ektron CMS version 8.5 SP2. 我正在使用Ektron CMS版本8.5 SP2。

I have some items in a taxonomy. 我在分类法中有一些项目。 Some are actual pages, some are library items (documents like Word files and PDFs). 有些是实际页面,有些是库项目(Word文件和PDF等文档)。

Let's say there are 3 pages and 2 library items for a total of 5 items in my taxonomy. 假设我的分类法中有3页和2个库项目,总共5个项目。

I use the following code... 我使用以下代码...

ContentManager cManager = new Ektron.Cms.Framework.Content.ContentManager();
Ektron.Cms.Content.ContentTaxonomyCriteria ctCriteria = new    Ektron.Cms.Content.ContentTaxonomyCriteria();
ctCriteria.AddFilter(1707, true); // hard coded taxonomy ID
List<ContentData> list = cManager.GetList(ctCriteria);
Label1.Text = list.Count.ToString();

When this code runs, the count of items in the list is 3. If I output the actual list, I can see it's only the pages in the taxonomy, not the 2 library items. 运行此代码时,列表中的项目数为3。如果输出实际列表,则可以看到它只是分类法中的页面,而不是2个库项目。

It seems that the ContentManager.getList() function does not get library items, even when those items have been added to the taxonomy. 似乎ContentManager.getList()函数无法获取库项目,即使这些项目已添加到分类法中也是如此。 I can confirm that in the admin workarea, the library items are visible in the taxonomy. 我可以确认在管理工作区中,库项目在分类法中可见。

For clarification, this is a problem with retrieving items that have already been added to the taxonomy. 为了澄清起见,这是检索已添加到分类法中的项目的问题。

Does anyone know how I can retirieve a list of all items in a taxonomy, including any library items in there. 有谁知道我如何检索分类法中所有项目的列表,包括其中的任何图书馆项目。

Note: If I add the files to the Document Managment System instead of the library, it works perfectly. 注意:如果我将文件而不是库添加到文档管理系统中,则它可以正常工作。 But in the live system, I have hundreds of items in the library and I'm hoping theres' a way to view them via a taxonomy without having to move them all into the DMS. 但是在实时系统中,我的库中有数百个项目,我希望有一种方法可以通过分类法查看它们,而不必将它们全部移入DMS。

I have posted this question on the Ektron developers forum as well, but I've had no reply. 我也已在Ektron开发人员论坛上发布了此问题,但没有得到任何回复。 I'm hoping somebody here can help. 我希望这里有人可以提供帮助。

Cheers. 干杯。

我看的是TaxonomyItemManager而不是ContentManager。

Thanks to @maddoxej suggestion of using the TaxonomyItemManager, I have working solution code... 感谢@maddoxej建议使用TaxonomyItemManager,我有了有效的解决方案代码...

TaxonomyItemCriteria criteria = new TaxonomyItemCriteria();
criteria.AddFilter(TaxonomyItemProperty.TaxonomyId, CriteriaFilterOperator.EqualTo, 1707);
TaxonomyItemManager taxonomyItemManager = new TaxonomyItemManager();
List<TaxonomyItemData> taxonomyItemList = taxonomyItemManager.GetList(criteria);
Label1.Text = taxonomyItemList.Count.ToString();

This code now shows the expected count of "5", and I can display all the itmes :) 现在,这段代码显示了预期的“ 5”计数,我可以显示所有的主题:)

So many "manager" classes in Ektron. Ektron中有很多“经理”类。

A follow up to my comment from the other day on @nedlud's answer, I felt like this deserved its own answer though. 在前几天我对@nedlud的答案发表评论之后,我觉得这应该得到自己的答案。

According to the Framework API docs : 根据Framework API文档

If intent is to retrieve CMS items that have been categorized in Taxonomies, use TaxonomyItemManager . 如果要检索已在分类中分类的CMS项目,请使用TaxonomyItemManager

But as already noted in the comments, the TaxonomyItemData objects returned by this API have a number of empty properties such as QuickLink and Html . 但是,正如注释中已经指出的那样,此API返回的TaxonomyItemData对象具有许多空属性,例如QuickLinkHtml I've found that using the TaxonomyManager , one can successfully query for items assigned to particular taxonomy categories. 我发现使用TaxonomyManager可以成功查询分配给特定分类法类别的项目。

Here's a brief snippet using the Framework API (version >= 8.5); 这是使用Framework API的简短代码段(版本> = 8.5); this feels reminiscent of working with the older (version <= 8.0) taxonomy API wherein one would create a TaxonomyRequest and get an object structure back that encapsulated not only the taxonomy iteself, but the items categorized into that taxonomy: 这让人想起使用较旧的(版本<= 8.0)分类标准API的情况,其中一个人将创建一个TaxonomyRequest并获得一个对象结构,该对象结构不仅封装了分类标准本身,而且还封装了分类标准中的项目:

//e.g. for a single-level taxonomy

long taxRoot = 1707; //from OP's question
TaxonomyManager taxManager = new TaxonomyManager();
//GetTree overload supplying includeItems parameter
TaxonomyData taxTree = taxManager.GetTree(taxRoot, includeItems: true);

foreach(TaxonomyItemData taxItem in taxTree.TaxonomyItems)
{
    //these should print true
    Response.Write(!String.IsNullOrEmpty(taxItem.QuickLink));
    Response.Write(!String.IsNullOrEmpty(taxItem.Html));
}

I'm currently refactoring some version 8.0 code into version 8.6 and converting to the Framework API. 我目前正在将8.0版的一些代码重构为8.6版,并转换为Framework API。 Until Ektron fixes the (bug?) of TaxonomyItemManager returning TaxonomyItemData with null properties, I'll be using the above method + LINQ for the sorting/filtering/etc. 直到晔固定的(错误?) TaxonomyItemManager返回TaxonomyItemData具有空性能,我将使用上述方法+ LINQ用于排序/过滤/等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM