you can get this information from the TaxonomyManager by first getting the Category Taxonomy, then iterating through the taxon items in that taxonomy.
Sitefinity creates default taxonomies for Categories (and Tags and Departments) so the Id is hard-coded in the manager. Here's a code sample that might help explain how it works:
// get the taxonomy manager to interact with taxonomy data
var mgr = TaxonomyManager.GetManager();
// get the Categories taxonomy
var categoriesTaxonomy = mgr.GetTaxonomy<HierarchicalTaxonomy>(TaxonomyManager.CategoriesTaxonomyId);
// get the list of category taxon items from the Categories Taxonomy
var categories = categoriesTaxonomy.Taxa;
// read through each category taxon and get the title
var categoryTitle = category.Title;
If you go the other way around, and get the Category property from the Content item (which returns TrackedList<Guid> of taxonomy ids), you can again use the manager to get the category names:
// Get list of category ids from content item field
var categoryIDs = contentItem.GetValue<TrackedList<Guid>>(
// get the matching taxon from the manager by Id
var categoryTaxon = mgr.GetTaxon<HierarchicalTaxon>(categoryId);
var categoryTitle = categoryTaxon.Title;
If you are working with Tags instead, you can replace HierarchicalTaxon
, and use the TaxonomyManager.TagsTaxonomyId
You could even use this to retrieve custom taxonomy items by searching the manager by title instead of Id (this also works with "Categories" or "Tags" but I like to use the Id since it's hard-coded):
var customTaxonomy = mgr.GetTaxonomies<HierarchicalTaxonomy>().FirstOrDefault(t => t.Title ==
"My Custom Taxonomy"
Notice this time we use GetTaxonomies
to retrieve them all, then filter to a matching item against your title. Once again the type depends on the Taxonomy type you're using (Hierarchical vs Flat).
I hope this is helpful!