Get Taxa of a Content item - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Get Taxa of a Content item

  • Get Taxa of a Content item
  • IQueryable<Video> videos = App.WorkWith().Videos().Get()

                    .Where(v => v.Status == ContentLifecycleStatus.Live);
                foreach (Video v in videos)

    I know Organizer is not the right attribute, but I haven't had much luck finding the taxa, specifically hierarchical taxa(categories), that a Video or any Content object belong to given the object. 

    Alternatively if I could *anonymously* access GET only on /sitefinity/services/content/videoservice.svc// that also might work. I just need the list of all videos and what categories they belong to. 

    I have developed a method starting from the taxonomy and getting associated videos but that ends up being n queries where n is the number of categories. Would the method of getting a content item then getting its associated taxa actually result in m queries in the backend where m is the number of videos? 

    If so I'll go with the taxonomy-first route. 


    Just throw me a free AJAX paged media gallery for video with user-selectable category filters starting at a specific point in the category hierarchy with a depth of 2 and the starting node invisible. Also different CSS classes for tier 1 and tier 2 categories. Hey, a guy can dream right?
  • Hello Adam,

    Please take a look at this forum post

    Ivan Dimitrov
    the Telerik team
  • I've seen that post. It was helpful in finding Content given a specific Taxonomy. I'm looking to find a full listing of all videos and their associated taxonomies. 

    Or were you suggesting the route of getting the taxonomies I am interested in first, then get all of the videos matching each taxonomy and merging the list? I was hoping for < O(2n).
  • Hello Adam,

    Each content item has a property GetValue where you can pass the dybanic filed name

    cnt.GetValue("Category"), so you can get the category for a specific item.

    Ivan Dimitrov
    the Telerik team

    There is no GetValue method according to both your docs and my own experimentation. How do I get that?

    I am writing my own WCF Service to avoid requiring authentication to get the video attributes. I will have to use the query by taxon method and merge lists when multiple categories are selected.

    So I have a solution now. I would still like to know how to call the GetValue method as it doesn't appear to be a member of any Content class I have worked with, but is referenced often on the forum.
  • Hello Adam,

    GetValue(string) method is an extension method defined on the type IDynamicFieldsContainer. In order to have this method available, please import following namespace in your class:


    Yes, I know that this is, suboptimal, to say the least. I'll try to see if and when we can move this into Telerik.Sitefinity namespace, because it would be more obvious.

    I hope this helps. 

    the Telerik team
  • so we can get the specific taxa list by specifying the taxonomy field via GetValue("taxonomyname")

    HOWEVER, this requires that we know in advance the name of the custom field storing the value. Is it possible, as the OP asked, to get a list of ALL taxonomies including their types from the content item directly without specifying the taxonomy name?

    For example, if I'm processing items via API and need to do something based on the taxonomy coming from different content types (Which may have different custom fields for taxonomy) I can't assume they have a field or not, so I want to be able to simply get a result of all the taxonomy and types and process it that way...

    is this not possible?
  • Hello Josh,

    You can use type descriptor to get all properties of the item and iterate them. Then you have to get the property descriptor and get the value.

    public void GetTaxons(IDynamicFieldsContainer item)
        var allProperties = TypeDescriptor.GetProperties(item);
        foreach (PropertyDescriptor propertyDescriptor in allProperties)
            if (propertyDescriptor is TaxonomyPropertyDescriptor)
                var value = item.GetValue<IList<Guid>>(propertyDescriptor.Name).ToArray();

    Radoslav Georgiev
    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.