我使用的是 Ektron CMS 8.5 SP2 版。
我在分类法中有一些项目。有些是实际页面,有些是库项目(Word 文件和 PDF 等文档)。
假设我的分类中有 3 个页面和 2 个图书馆项目,总共有 5 个项目。
我使用下面的代码...
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();
当这段代码运行时,列表中的项目数是 3。如果我输出实际列表,我可以看到它只是分类中的页面,而不是 2 个库项目。
ContentManager.getList() 函数似乎无法获取库项目,即使这些项目已添加到分类中也是如此。我可以确认在管理工作区中,库项目在分类中可见。
澄清一下,这是检索已经添加到分类中的项目的问题。
有谁知道如何检索分类法中所有项目的列表,包括其中的任何图书馆项目。
注意:如果我将文件添加到文档管理系统而不是库,它会完美运行。但在实时系统中,我的图书馆中有数百个项目,我希望有一种方法可以通过分类法查看它们,而不必将它们全部移动到 DMS 中。
我也在 Ektron 开发者论坛上发布了这个问题,但没有得到回复。我希望这里有人可以提供帮助。
干杯。
最佳答案
我前几天对@nedlud 的回答的评论的跟进,我觉得这应该得到自己的回答。
If intent is to retrieve CMS items that have been categorized in Taxonomies, use TaxonomyItemManager.
但是正如评论中已经指出的那样,此 API 返回的 TaxonomyItemData
对象具有许多空属性,例如 QuickLink
和 Html
.我发现使用 TaxonomyManager
,可以成功查询分配给特定分类类别的项目。
这是一个使用 Framework API(版本 >= 8.5)的简短片段;这让人想起使用旧的(版本 <= 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));
}
我目前正在将一些 8.0 版代码重构为 8.6 版并转换为框架 API。在 Ektron 修复 TaxonomyItemManager
返回具有空属性的 TaxonomyItemData
的(错误?)之前,我将使用上述方法 + LINQ
进行排序/过滤/等
关于c# - 如何在 Ektron 中选择属于分类法的图书馆项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12381065/