Getting Tags associated to a document

Posted by Community Admin on 05-Aug-2018 15:51

Getting Tags associated to a document

All Replies

Posted by Community Admin on 10-May-2011 00:00

Hello,
can anyone please tell me how can I get the tags associated to a document using Taxonomies?
Thanks

Posted by Community Admin on 10-May-2011 00:00

Hi Paolo,

Here is a sample code that shows how to get all Categories for a given content item ( in my case news)

var dataItem = App.WorkWith().NewsItems().Get().First();
            var propDesc = OrganizerBase.GetProperty(dataItem.GetType(), "Category") as TaxonomyPropertyDescriptor;
            if (propDesc != null)
           
                var taxonIds = propDesc.GetValue(dataItem) as IList<Guid>;
                var taxonomyManager = TaxonomyManager.GetManager();
                var taxa = new List<string>();
                foreach (var taxonId in taxonIds)
               
                    taxa.Add(taxonomyManager.GetTaxon(taxonId).Title);
               

           

The same code can be used for Tags and all other content items.




Regards,
Ivan Dimitrov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

This thread is closed