简体   繁体   English

Ektron:更改内容分类

[英]Ektron: Change taxonomy of content

I have a bunch of content items in Ektron that all have taxonomies assigned to them. 我在Ektron中有一堆内容项,所有内容项都分配有分类法。 I'm trying to write a method that will update the taxonomies based on a spreadsheet, where each row in the spreadsheet has the ID of a content item and the updated taxonomies that should be assigned to it. 我正在尝试编写一种方法,该方法将基于电子表格更新分类法,其中电子表格中的每一行都有内容项的ID和应分配给它的更新的分类法。 So, I have the content ID and the taxonomy IDs, but I'm not sure what to do with them. 所以,我有内容ID和分类ID,但是我不确定该如何处理。

What method do I use to change the taxonomies of my content items? 如何使用什么方法更改内容项的分类法?

You need to use the ContentManager class in order to update the taxonomies for a given item. 您需要使用ContentManager类来更新给定项目的分类法。

Here you have an example about how to retrieve already assigned taxonomies: https://developer.ektron.com/forums/?v=t&t=3033 这里有一个有关如何检索已分配的分类法的示例: https : //developer.ektron.com/forums/?v= t & t =3033

I guess what you need is: 我想您需要的是:

Get all assigned taxonomies 获取所有分配的分类法

var contentManager = new ContentManager(ApiAccessMode.Admin);
var taxonomyDataList = contentManager.GetAssignedTaxonomyList(contentId, language);

Remove those taxonomies from the item (iterating the previous list) 从项目中删除那些分类法(重复上一个列表)

contentManager.RemoveTaxonomy(contentId, taxonomyId);

Assign the new taxonomy, coming from the excel document. 分配来自Excel文档的新分类法。

contentManager.AssignTaxonomy(contentId, taxonomyId);

NOTES: 笔记:

  • It is important to instantiate your ContentManager with Admin mode in order to update whatever content you have in your system, no matter the permissions they have. 重要的是要使用Admin模式实例化ContentManager,以更新系统中拥有的任何内容,无论它们具有的权限如何。

  • You need to execute this within a context of a Web Request. 您需要在Web请求的上下文中执行此操作。 If you build a console application and reference Ektron binaries, that probably won't work as many methods rely on a HttpContext. 如果您构建控制台应用程序并引用Ektron二进制文件,则可能无法使用,因为许多方法依赖HttpContext。

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

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