简体   繁体   中英

Ektron: Change taxonomy of content

I have a bunch of content items in Ektron that all have taxonomies assigned to them. 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. So, I have the content ID and the taxonomy IDs, but I'm not sure what to do with them.

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.

Here you have an example about how to retrieve already assigned taxonomies: 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.

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.

  • You need to execute this within a context of a Web Request. If you build a console application and reference Ektron binaries, that probably won't work as many methods rely on a HttpContext.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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