SaaS CMS has officially launched! Learn more now.

AvailablePageTypes(Availability.None)

Vote:
 

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:

    [SiteContentType(
        DisplayName = "Article Page",
        GUID = "b6e7c4d6-5e29-4b8f-80a9-2ae79859c8ce",
        Description = "")]
    [SiteImageUrl]
    [AvailablePageTypes(Availability.None)]

    public class ArticlePage : SitePageData {
    ...

    

What am I doing wrong?

#73688
Aug 06, 2013 7:38
Vote:
 

I am running patch 3 (well v 7.0.586.16, is this patch 3?)

#73689
Aug 06, 2013 7:39
Vote:
 

I believe you still need to add a dummy page type to list in AvailablePageTypes(). On the dummy page type you set AvailableInEditMode = false.

#73691
Aug 06, 2013 9:17
Vote:
 

I was wrong. [AvailablePageTypes(Availability.None)] works for me when I try it now. You probably have some kind of model sync problem.

#73715
Aug 06, 2013 19:11
Vote:
 

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?

#73718
Aug 07, 2013 1:19
Vote:
 

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";
}
}

 

#73725
Aug 07, 2013 9:37
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.