Try our conversational search powered by Generative AI!

Add Category to a page

Vote:
 

I are having problem find out how programmatically add a category to a page.

Can anyone share some insight on how this is done?

#90867
Sep 19, 2014 13:52
Vote:
 

Hi,

You can do something like this

var category = new Category("Name", "Description");

Category.GetRoot().Categories.Add(category);

var categories = CurrentPage.Category;

categories.Add(category.ID);

var page = CurrentPage.CreateWritableClone();
page.Category = categories;

ServiceLocator.Current.GetInstance().Save(page, SaveAction.Publish);
#90882
Sep 19, 2014 18:17
Vote:
 

Thanks ;) made my monday

#90895
Sep 22, 2014 8:19
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.