+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Extending Categories

Extending Categories

5 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    22 Nov 2010
    Link to this post
    Hi,

    I looked in the developer manual for an answer, but the content related to categories seems a bit dated...the developer manual itself says version 3.2 SP2 under "What is New in This Sitefinity Version" and there's no information I can find about how to work with them since the hierarchical categories were added.  Is there newer documentation somewhere for the Categories API? 

    I'd like to extend Sitefinity in order to add a second property that works like Category.  I know I can add custom metafields to generic content items, but I'd like to manage the allowed values for the property in the same way I can for categories.  Specifically, I'd to add a Location, so that I can categorize content like:

    United States
        Georgia
            Atlanta
        California
            San Francisco
            Los Angeles
    Europe
        Great Britain
            London
        Italy
            Roma
            Napoli

    And so on.  The reason is that it would be easier to get a list of unique categories, in order to provide a pick list of, for example, locations in California.  Then I could easily get a list of content items related to that location.  I'm going to do this in a separate content provider based on Generic Content.

    I'd rather not use categories themselves for this--I still want to be able to use them for other things.  Is this possible?

    Thanks in advance,
    Mike Sharp
  2. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    22 Nov 2010
    Link to this post
    Oh, one more thing.  It would be really nice if I could add properties to category.  For example, I'd like to add an X and Y coordinate to each category so that I can position the link for a category over an image of a map.  Possible?
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Nov 2010
    Link to this post
    Hi Mike,

    Category is a data object and it uses ICategory interface. Generally each category is persisted as a meta data. You can create a new new meta key (User Manual section page 214 ,Adding Custom Fields)

    You can create a custom control with predefined countries, otherwise you need a custom persistence class that will get and update the data.

    For providing coordinates you can use Geomapping editor control

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Mark
    Mark avatar
    12 posts
    Registered:
    10 Feb 2011
    24 Mar 2011
    Link to this post
    Hi Ivan/Mike,

    This is really the only thread I can find on extending categories and looking in the manual doesn't really provide any help either.  I have been able to add custom meta fields to Generic_Content, however I would like to be able to add something similar to categories, for example an image, so when creating a category you can set the "Name", "Subcategory of" and have an image selector to choose an image from a library.  Is this possible?

    Looking at the web.config and in particular the metaField element, there isn't anything like Category.Name, Category.Subcategoryof so I'm not sure how I'd be able to add an extra meta field.

    Mike you mention adding an x/y coordinate property to the category in your previous post, did you achieve this in the end? any chance you can provide an example or explanation of how you implemented this?

    Any help is much appreciated, Thanks in advance
    Mark
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    30 Mar 2011
    Link to this post
    Hello Mike,

    The Category itself is a metakey. If you want to add a new metakey you can declared it in the web.config or create it dynamically. For selecting items from a library you can use the ButtonSelector. You can observe NewsItemNew external template  ( how to map a template).

    Regards,
    Ivan Dimitrov
    the Telerik team
Register for webinar
5 posts, 0 answered