Displaying categories

Vasyl Chepil asked on March 16, 2016 15:10

I have kentico web app project. On page i need to show "tiles" for all blogs and there categories that i have. For this i'm using web part Repeater and assign it custom transformation. All blog info except categories is showing good.

To show blog categories i'm triing to us an example i've found on your site https://docs.kentico.com/display/K8/Example+-+Displaying+categories+in+document+lists

<article class="blog_item {% if (DisplayIndex == 0) {"big"} else {if (DisplayIndex == 5) {"medium"} else {""}} #%}">
  <div class="blog_item_details">
    <div class="blog_item_category">   
      {% GetBlogCategories(DocumentID, null) %}
     </div>
    <div class="blog_item_title">
      <a href="{% GetDocumentUrl() %}">{% title %}</a>
    </div>
    <div class="blog_item_footer">
       {% GetDateTime(BlogPostDate, "MMM. dd, yyyy") #%} | By <a href="{% CustomGetMemberProfileUrl(NodeOwner) %}">{% GetUserFullName(NodeOwner) %}</a>{%CustomGetBlogCoAutorsNames(NodeID)%}
    </div>
  </div>
</article>

What i'm doing wrong? Error: Exception occured while evaluation of the expression ' GetBlogCategories(DocumentID, null) ': Method 'GetBlogCategories' for object of type 'System.Int32' not found, please check the macro or the method declaration.

PS The example is for ASCX transformation type but i`m using TEXT/XML.

Recent Answers


Dawid Jachnik answered on March 16, 2016 15:42

Hello,

"The example is for ASCX transformation type but i`m using TEXT/XML."

That's the problem. The recolve this change this to ASCX transformations or create GetBlogCategories(..) function in the macro syntax. Almost everything is the same, only "envelope" need to be changed.

Example of custom macros

3 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 16, 2016 15:43 (last edited on December 10, 2019 02:30)

The example shown is using ascx transformation, and the methods are not the same. There may not even be a macro in k# for that, but there is one I believe that is {% currentdocument.categories|(identity)GlobalAdministrator%} (or similar) that you can then use k# transformation on to display.

https://docs.kentico.com/pages/viewpage.action?pageId=4621391

0 votesVote for this answer Mark as a Correct answer

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