Display Tags and Categories in a single transformation

Tonka Penkova asked on April 9, 2015 13:58

Hi, everybody! I’ve been struggling with an issue for the last two days, so I’ve decided that some of you can help me. I need to display the categories and the tags an article has and each category/tag has to be a link to a page with all the articles from the certain category/tag. I need to do this in the article transformation. It has to be something like that:

Categories: <a href="#">Category One</a> <a href="#">Category Two</a> | Tags: <a href="#">Tag One</a> <a href="#">Tag Two</a>

Thank you!

Recent Answers

Brenden Kehren answered on April 9, 2015 14:08

See this example for displaying categories for a page.

For tags this is what is used out of the box, I don't think there would be a problem using the function for other page types. Key with this is to ensure your pages have a tag group assigned to them.

<%# IfEmpty(Eval("DocumentTags"),"","Filed under: " + BlogFunctions.GetDocumentTags(Eval("DocumentTagGroupID"), Eval("DocumentTags"), "~/Blog")) %>
1 votesVote for this answer Mark as a Correct answer

Stephen Rushing answered on April 12, 2015 21:49 (last edited on December 10, 2019 02:30)

I was trying to show a document's categories with a static text web part, so this may be relevant if you're using an HTML transformation, rather than ASCX:

{% foreach(cat in Documents[DocumentID].Categories){ print("<a href='"+ ResolveURL("~/wherever?category=" + cat.CategoryID) + "'>" + cat.CategoryDisplayName + "</a>"); } |(identity)GlobalAdministrator%}

Depending on the context, you could use CurrentDocument.Categories instead of Documents[DocumentID].Categories.

0 votesVote for this answer Mark as a Correct answer

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