Hello,
I am currently using a transformation in a Repeater to display blog articles. However, I am having issues with Categories.
The category shows well inside the article (using CurrentDocument.Categories), however I can't get the equivalent to work in a transformation with the data returned.
I have currently:
<div class="blog-item-container"> <div class="blog-item"> <div class="blog-category">{% Documents[DocumentID].Categories.FirstItem.CategoryDisplayName %}</div> {% if (DocumentPageImage != null) { %}<div class="img-wrapper"><a href="{% GetDocumentUrl() %}"><img class="blog-img" src="~/CMSPages/GetFile.aspx?guid={% DocumentPageImage %}" alt=""></a></div>{% } #%} <h4><a href="{% GetDocumentUrl() %}">{% DocumentPageTitle %}</a></h4> <p>{% DocumentPageDescription %}</p> </div> </div>
The problem line :
{% Documents[DocumentID].Categories.FirstItem.CategoryDisplayName %}
However, even though it returns a category for half the articles, it always return the same category and it is even the wrong one. I can filter by categories and everything, but my blog page shows the wrong categories in the listing. How should I go about to display categories in a repeater transformation? Is there seriously no built-in method to do it in a macro? All my articles only have 1 selected category. I just need to show the "first one".
Thanks,
Nathalie
Try this {% Documents[NodeAliasPath].Categories.FirstItem.CategoryDisplayName |(identity)GlobalAdministrator%}
{% Documents[NodeAliasPath].Categories.FirstItem.CategoryDisplayName |(identity)GlobalAdministrator%}
Thanks Rui! This works perfectly! I didn't think about the NodeAliasPath when I was looking for alternative options. I'll know better for the next time.
Please, sign in to be able to submit a new answer.