November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
I tried to reproduce this on an Alloy site running CMS Core 11.5.4 with following code:
var categoryRepository = ServiceLocator.Current.GetInstance<CategoryRepository>(); var shippingCategory = categoryRepository.Get("Shipping"); if (shippingCategory == null) { var parentCategory = categoryRepository.Get("Faq"); shippingCategory = new Category(parentCategory, "Shipping") { Selectable = true, Description = "Shipping" }; categoryRepository.Save(shippingCategory); } var faqQuestionPage = ServiceLocator.Current.GetInstance<IContentRepository>().GetDefault<StandardPage>(currentPage.ContentLink); faqQuestionPage.Name = "faq"; faqQuestionPage.Category.Add(shippingCategory.ID); ServiceLocator.Current.GetInstance<IContentRepository>().Save(faqQuestionPage, EPiServer.DataAccess.SaveAction.Publish, AccessLevel.NoAccess);
In my case the created faqQuestionPage will get the Category and it shows up as expected in edit mode.
Hi,
I need to programmatically create some pagetypes that have a CategoryList property in them.
I add some categories to this list, but when checking the database table 'tblContentCategory' the fields 'CategoryType' and 'ScopeName' are equal to 0.
The 'fkCategoryID' is filled in correctly however.
Those zeroes are probably the reason that the CategoryList field on the admin-side is empty although there are categories associated with the page since there are rows in 'tblContentCategory'.
When I add another instance of that new page-type programmatically and check that table again, I see one new row for each category (same categories I used when creating them programmatically) in this categorylist where the fields 'CategoryType' and 'ScopeName' are not equal to 0 but filled in correctly.
What could be the cause for this?
Here's a code snippet of how I create my page
Here's a code snippet of how I create my categories.