Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
Help shape the future of CMS PaaS release notes! Take this quick survey and share your feedback.
I believe you still need to add a dummy page type to list in AvailablePageTypes(). On the dummy page type you set AvailableInEditMode = false.
I was wrong. [AvailablePageTypes(Availability.None)] works for me when I try it now. You probably have some kind of model sync problem.
Thanks Johan, in response to your comment, I created a new identical class and setting AvailablePageTypes(Availability.None) did work. After confirming this, I went into the Admin and in the Available Page Types tab for the pagetype, I selected "Use Default Settings" and it appeared to obtain the correct settings.
At no point had I changed this setting in the CMS.
Is there someway to force all pagetypes to reload from code?
We are planning to release a developer Addon with some tools for development/debugging which will include a way to view and reset types/properties that are not in sync with code.
But for now you could quite easily write e.g. a scheduled job that iterates over all types and all properties and call Reset on them. The code could look something like:
[ScheduledPlugIn(DisplayName = "Revert to model")]
public class ResetTypes
{
public static string Execute()
{
return Execute(ServiceLocator.Current.GetInstance<IContentTypeRepository>(),
ServiceLocator.Current.GetInstance<IPropertyDefinitionRepository>(),
ServiceLocator.Current.GetInstance<IAvailableSettingsRepository>());
}
public static string Execute(IContentTypeRepository contentTypeRepository,
IPropertyDefinitionRepository propertyDefinitionRepository,
IAvailableSettingsRepository availableSettingsRepository)
{
foreach (var contentType in contentTypeRepository.List())
{
availableSettingsRepository.ClearSetting(contentType.Name);
var writableType = contentType.CreateWritableClone() as ContentType;
writableType.ResetContentType();
contentTypeRepository.Save(writableType);
foreach (var property in contentType.PropertyDefinitions)
{
var writableProp = property.CreateWritableClone();
writableProp.ResetPropertyDefinition();
propertyDefinitionRepository.Save(writableProp);
}
}
return "All changes from admin mode reverted";
}
}
I want to have some page types that do not allow child pages. I would assume setting [AvailablePageTypes(Availability.None)] would achieve this but this does not appear to be the case, all page types are currently shown.
My model class begins with:
What am I doing wrong?