London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Add Category to a page

Vote:
0

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:
0

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:
0

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.