Create Category Links in Kentico

by Joel Dahlin on November 20, 2015

Create Category Links in Kentico

If you look at all my blog posts I place them in categoies and then on the detail page I have links to all the categories that blog post is in.

I use a Repeater with custom query webpart to build these links.

Here are my Webpart settings:

  • Web part control ID: cats (short name)
  • Web part title: Categories (easily identifiable in the design view)
  • Query name: CMS.BlogPost.GetDocumentCategories (query below)
  • ORDER BY expression: (I left this blank and just hard-coded it in my query but could have put it here)
  • WHERE condition : DocumentID = {% CurrentPageInfo.DocumentID #% }
  • Selected columns : (again I left blank and hard-coded it in the query)
  • Transformation name: CMS.BlogPost.BreadcrumCategories (transformation below)
  • HTML Envelope - Content before: <ol class="breadcrumbs clearfix">
  • HTML Envelope - Content after: </ol>
  • Performance - Disable view state: checked (since I am not using it and to help with performance)
  • everything else was left as default

Custom Query

  • Query name: CMS.BlogPost.GetDocumentCategories
  • Query type: Query text
  • Requires transaction: unchecked
  • Query text:
SELECT CategoryDisplayName, CategoryName
FROM CMS_Category
WHERE CategoryParentID = 11 AND CategoryID IN(SELECT CategoryID FROM cms_DocumentCategory WHERE (##WHERE##))
ORDER BY CategoryCount DESC

CategoryParentID = 11 is the parent category of all my blog categories.


  • Transformation name: BreadcrumbCategories
  • Transformation type: ASCX
<li>// <a href="~/blog/category/<%# Eval("CategoryName") %>/"><%# Eval("CategoryDisplayName") %></a></li>

There you have it, an easy way to create friendly links for the categories of the current page.

#"how to" #macro #tip

Blog post currently doesn't have any comments.
 Security code