How to select library items related to taxonomy in Ektron

I am using Ektron CMS version 8.5 SP2.

I have some points in taxonomy. Some of them are actual pages, some of them are library items (documents such as Word files and PDF files).

Suppose in my taxonomy there are 3 pages and 2 library items for a total of 5 items.

I am using 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 works, the number of elements in the list is 3. If I display the actual list, I can see it only in taxonomy pages, and not in two library elements.

The ContentManager.getList () function does not seem to receive library elements, even if these elements were added to the taxonomy. I can confirm that in the administration area library items are visible in a taxonomy.

For clarification, this is a problem with retrieving elements that are already added to the taxonomy.

Does anyone know how I can restore a list of all the elements in a taxonomy, including any library elements.

Note. If I add files to the document management system instead of the library, it works fine. But in a living system, I have hundreds of items in the library, and I hope they can view them through a taxonomy without having to move them all to DMS.

I also posted this question on the Ektron Developer Forum, but I had no answer. I hope someone here can help.

Greetings.

+4
source share
3 answers

Follow my comment from another day on the @nedlud answer, I felt like it deserves my own answer.

According to the wireframe API documentation :

If the goal is to retrieve CMS elements that have been classified in taxonomies, use the TaxonomyItemManager .

But as noted in the comments, the TaxonomyItemData objects returned by this API have a number of empty properties, such as QuickLink and Html . I found that with the help of TaxonomyManager you can successfully query the elements assigned to certain categories of taxonomy.

The following is a brief snippet that uses the Framework Framework (version> = 8.5); this is similar to working with an older (version <= 8.0) taxonomic API in which you could create a TaxonomyRequest and get the structure of the object back, which encapsulated not only the taxonomy, but the elements classified into this taxonomy:

 //eg for a single-level taxonomy long taxRoot = 1707; //from OP 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 am currently converting version 8.0 code to version 8.6 and converting to the Framework API. Until Ektron fixes (error?) A TaxonomyItemManager that returns TaxonomyItemData with zero properties, I will use the + LINQ method described above to sort / filter / etc.

+2
source

I would look at TaxonomyItemManager and not at ContentManager.

+2
source

Thanks to @maddoxay suggesting using TaxonomyItemManager, I have a working solution code ...

 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 number of "5", and I can display all its themes :)

There are so many class managers at Ektron.

+2
source

Source: https://habr.com/ru/post/1433700/


All Articles