XbK - Taxonomy Retrieval

Julian C. asked on May 4, 2025 18:32

On XbK, I have a page content type with a field called Categories as taxonomy data type. I'm trying to retrieve the Categories tags associated with a page. I'm able to retrieve the tags GUIDs but the TagReference class only allows Identifier property. How do I convert the tag GUID to tag Name so the tag name actually displays? This is an example on how I successfully retrieve the Categories tags (GUIDs) associated with a page in my View:

@foreach (var pageItem in Model) { @foreach (var tag in pageItem.Categories) { @tag.Identifier } }

Recent Answers


Juraj Ondrus answered on May 5, 2025 05:15

For XbK related issues please use the Xperience community portal instead. This forum is more focused on Kentico Xperience 13.

0 votesVote for this answer Mark as a Correct answer

Rahul Kumawat answered on May 5, 2025 20:28

You can use ITaxonomyRetriever to retrieve the taxonomy and its tags which will include all of the tag fields -

// An instance of ITaxonomyRetriever (e.g., obtained via dependency injection) private readonly ITaxonomyRetriever taxonomyRetriever;

// Retrieves the general TaxonomyData object for a selected taxonomy TaxonomyData taxonomyData = await taxonomyRetriever .RetrieveTaxonomy(CategoryName, "en");

// Retrieves the tag by Identifire Tag tag = taxonomyData.Tags.Where(x => x.Identifier = tag.Identifier).FirstOrDefault(); string tagDisplayName = tag.Title; string tagCodeName = tag.Name;

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.