问题
I'm using Ektron CMS version 8.5 SP2.
I have some items in a taxonomy. Some are actual pages, some are library items (documents like Word files and PDFs).
Let's say there are 3 pages and 2 library items for a total of 5 items in my taxonomy.
I use 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 runs, the count of items in the list is 3. If I output the actual list, I can see it's only the pages in the taxonomy, not the 2 library items.
It seems that the ContentManager.getList() function does not get library items, even when those items have been added to the taxonomy. I can confirm that in the admin workarea, the library items are visible in the taxonomy.
For clarification, this is a problem with retrieving items that have already been added to the taxonomy.
Does anyone know how I can retirieve a list of all items in a taxonomy, including any library items in there.
Note: If I add the files to the Document Managment System instead of the library, it works perfectly. But in the live system, I have hundreds of items in the library and I'm hoping theres' a way to view them via a taxonomy without having to move them all into the DMS.
I have posted this question on the Ektron developers forum as well, but I've had no reply. I'm hoping somebody here can help.
Cheers.
回答1:
A follow up to my comment from the other day on @nedlud's answer, I felt like this deserved its own answer though.
According to the Framework API docs:
If intent is to retrieve CMS items that have been categorized in Taxonomies, use TaxonomyItemManager.
But as already noted in the comments, the TaxonomyItemData
objects returned by this API have a number of empty properties such as QuickLink
and Html
. I've found that using the TaxonomyManager
, one can successfully query for items assigned to particular taxonomy categories.
Here's a brief snippet using the Framework API (version >= 8.5); this feels reminiscent of working with the older (version <= 8.0) taxonomy API wherein one would create a TaxonomyRequest
and get an object structure back that encapsulated not only the taxonomy iteself, but the items categorized into that taxonomy:
//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));
}
I'm currently refactoring some version 8.0 code into version 8.6 and converting to the Framework API. Until Ektron fixes the (bug?) of TaxonomyItemManager
returning TaxonomyItemData
with null properties, I'll be using the above method + LINQ
for the sorting/filtering/etc.
回答2:
I would look at the TaxonomyItemManager rather than the ContentManager.
回答3:
Thanks to @maddoxej suggestion of using the TaxonomyItemManager, I have 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 count of "5", and I can display all the itmes :)
So many "manager" classes in Ektron.
来源:https://stackoverflow.com/questions/12381065/how-to-select-library-items-that-belong-to-a-taxonomy-in-ektron