Try our conversational search powered by Generative AI!

How to get selected categories

Vote:
 

Hi!

How can I collect/read what categories are selected on a page (selected in edit mode - from the tab)...? I would like to have all selected categories in some kind of list/array.

I'm having different events and I'm trying to create a page that will display surtain events... depending on what category (or categories) are selected.

#73936
Aug 14, 2013 16:50
Vote:
 

If you have the PageData object you can get all the category ids that are selected using: CurrentPage.Category (where CurrentPage is a PageData object) which returns a CategoryList. You can then use Category.Find() (static method) to get the Category object for each item in the CategoryList.

Hope this helps.

Frederik

#73944
Aug 14, 2013 21:05
Vote:
 

Thank you! I think it will...

#73951
Aug 15, 2013 8:17
Vote:
 

For anyone interested in the above... I managed to get a list (string) of the selected category names with this method:

 public string getCatNames(CategoryList c)
        {
            string temp = "";
            Category cat;
            for (int i = 0; i < c.Count; i++)
            {
                cat = Category.Find(c.ElementAt(i));
                temp += cat.Name+","; 
            }
            temp = temp.TrimEnd(',');

            return temp;
        }

    

#73954
Aug 15, 2013 10:20
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.