Question

We recently upgraded from Ektron 8.6 to 9.0 (Ektron CMS400.NET, Version: 9.00 SP2(Build 9.0.0.249)).

I have some code (below) which we use to display links to items in a taxonomy. Under 8.6, this would show library items if they had been added to the taxonomy. As of 9.0, it no longer displays library items. It still works for DMS items and normal pages (all first class content in Ektron).

private List<ContentData> getTaxonomyItems(long TaxonomyId)
{
    listContentManager = new ContentManager();
    criteria = new ContentTaxonomyCriteria(ContentProperty.Id, EkEnumeration.OrderByDirection.Ascending);

    criteria.PagingInfo = new Ektron.Cms.PagingInfo(400); // there's a lot of items and I don't want to page them.

    criteria.AddFilter(TaxonomyId, true); // this gets sub taxonomies too :)

    List<ContentData> contentList = listContentManager.GetList(criteria);

    return contentList;
}

(I would love to simply say to users to use the DMS instead of the library, but we have a security requirement and I'm not aware of a way I can enforce security on DMS items like we can with library items by dropping a webconfig file in the library folder.)

Is this a bug that anyone else has experienced? Or is there a problem with my code (did an API change in the upgrade to 9.0)?

Thanks.

Was it helpful?

Solution

I ended up emailing Ektron support in Sydney (I'm in Australia), and they said:

I would expect ContentManager to only return content, not library items – must have been a loophole which is now closed. Taxonomy is the way to go.

So I used some of the code they provided and came up with the following, which appears to work...

private List<TaxonomyItemData> getTaxonomyItems(long TaxonomyId)
{
    List<TaxonomyItemData> list = new List<TaxonomyItemData>();

    TaxonomyManager taxManager = new TaxonomyManager(Ektron.Cms.Framework.ApiAccessMode.Admin);
    TaxonomyCriteria taxonomyCriteria = new Ektron.Cms.Organization.TaxonomyCriteria();
    taxonomyCriteria.AddFilter(Ektron.Cms.Organization.TaxonomyProperty.Path,
        Ektron.Cms.Common.CriteriaFilterOperator.StartsWith, GetTaxonomyPathById(TaxonomyId));
    List<TaxonomyData> TaxonomyDataList = taxManager.GetList(taxonomyCriteria);

    foreach (TaxonomyData taxd in TaxonomyDataList)
    {
        TaxonomyData taxTree = taxManager.GetTree(taxd.Path,
        1, // depth. doesn't seem to work. have to manually tranverse lower taxonomies.
        true, // include items
        null,
        Ektron.Cms.Common.EkEnumeration.TaxonomyType.Content,
        Ektron.Cms.Common.EkEnumeration.TaxonomyItemsSortOrder.taxonomy_item_display_order);

        foreach (TaxonomyItemData taxItem in taxTree.TaxonomyItems)
        {
            list.Add(taxItem);
        }
    }
    return list;
}

private static String GetTaxonomyPathById(long taxonomyId)
{
    TaxonomyManager tMgr = new TaxonomyManager();
    TaxonomyData tData = tMgr.GetItem(taxonomyId);
    if (tData != null)
    {
        return tData.Path;
    }
    return "";
}

This code fetches items for all the child taxonomies as well as returning library items. The one problem is that it fetches duplicates for some items, but those are easy to clean out.

I was also told by Ektron that...

TaxonomyManager.GetItem(“{path}”) is a more efficient way to get the categories

That's why I've included the GetTaxonomyPathById() method (inspired by this blog post: http://www.nimbleuser.com/blog/posts/2009/iterating-through-ektron-content-in-multiple-taxonomies-via-directly-interfacing-with-search-indexing-services/ )

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top