API
Version 7.x > API > Add custom properties to a category View modes: 
User avatar
Member
Member
sammy - 1/24/2014 7:48:01 AM
   
Add custom properties to a category
Hi all,
I haven't delved to deep into this, but I'm wondering if this can be done.

I want to have a "Category" page on my Kentico site.

Depending upon which Category the user is browsing, I would like some custom icons, text, and colors, to show up on the right-hand side of the page.

Currently Catetgories don't have custom properties.

Is there a way of extending the Categories object in the CMS desk, to show these custom properties to the user?

Thanks!

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/24/2014 8:00:16 AM
   
RE:Add custom properties to a category
Sounds like a place for custom document type(s).

User avatar
Member
Member
sammy - 1/24/2014 8:03:58 AM
   
RE:Add custom properties to a category
I was thinking of going that route.

Except the same can belong to multiple categories.

So, how could you add the same product to different document types?

Also, there can be a lot of categories (>50). So, I figured it might be easier to just populate category properties, and an easier place to change (rather than pulling up each document, when I need to change properties).

User avatar
Member
Member
sammy - 1/24/2014 8:04:45 AM
   
RE:Add custom properties to a category
(is there some way of editing posts)

This
Except the same can belong to multiple categories.
should be
Except the same *product* can belong to multiple categories.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 1/29/2014 6:47:14 AM
   
RE:Add custom properties to a category
Ok I take back my original statement then. You could do this with the built-in categories by simply looking at the categories assigned to the document. If the user is in a specific part of the site and the document has that category assigned to it, display one image. If they are in another part of the site and that same document has the other category assigned to it, display a different image.

You can use something like this to get the categories: (I'm comparing the category name to the document name in this instance)
{%"DocumentID IN (SELECT DocumentID from CMS_DocumentCategory inner join CMS_Category on CMS_DocumentCategory.CategoryID = CMS_Category.CategoryID where (CategoryDisplayName = '" + CurrentDocument.DocumentName + "' OR CategoryDisplayName = 'All'))"|(handlesqlinjection)false@%}