Reputation: 4853
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?
Upvotes: 0
Views: 129
Reputation: 376
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.
Upvotes: 1