You can restrict what page types are allowed to be created as children. Decorate your content type with
http://world.episerver.com/documentation/Class-library/?documentId=cms/9/145DE4A6
An example for root page
[ContentType(GUID = "3415B788-8359-4BF0-9375-2FE9BA90719B", AvailableInEditMode = false)] [AvailableContentTypes(Include = new[] { typeof(StartPage), typeof(ContainerPage))] public class SysRoot : PageData { }
This approach is not working in the current CMS version 11.
Does anybody knows how to accomplish this in version 11?
[ContentType(
GUID = "19671657-B684-4D95-A61F-8DD4FE60D559",
GroupName = Global.GroupNames.Specialized)]
[SiteImageUrl]
[AvailableContentTypes(
Availability.Specific,
Include = new[] { typeof(ContainerPage), typeof(ProductPage), typeof(StandardPage), typeof(ISearchPage), typeof(LandingPage), typeof(ContentFolder) }, // Pages we can create under the start page...
ExcludeOn = new[] { typeof(ContainerPage), typeof(ProductPage), typeof(StandardPage), typeof(ISearchPage), typeof(LandingPage) })] // ...and underneath those we can't create additional start pages
public class StartPage : SitePageData
{
//properties...
}
It's pretty similar. You get some options on the Availability flag to choose between including All, None or Specific. Choose specific and then set the Include to all pages types you want should be available under this page type. If you want to exclude this page type below some other page types, you can use the ExcludeOn property. Normally I only use the Include option...
Thanks for the reply, but that is restriction for the StartPage. I want to add a restriction to the Root page like is it show in the post above.
I.e. Under the site's Root to be able to add only the StartPage and SettingsPage type.
For root page type specifically I haven't tried it no. Saw a blog post about it though
I saw that blog post too and that I used in my example and it's not working in CMS 11.
Thank you again for your assistance.
Hi Nenad,
The only way I believe you can do this for the Root is via the IAvailableSettingsRepository.
I've had success with the following previously:
[InitializableModule]
[ModuleDependency(typeof(CmsCoreInitialization))]
public class RestrictRootPagesInitialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
var contentTypeRepository = context.Locate.Advanced.GetInstance<IContentTypeRepository>();
var sysRoot = contentTypeRepository.Load("SysRoot") as PageType;
var setting = new AvailableSetting { Availability = Availability.Specific };
setting.AllowedContentTypeNames.Add(contentTypeRepository.Load<StartPage>().Name);
setting.AllowedContentTypeNames.Add(contentTypeRepository.Load<ContainerPage>().Name);
var availableSettingsRepository = context.Locate.Advanced.GetInstance<IAvailableSettingsRepository>();
availableSettingsRepository.RegisterSetting(sysRoot, setting);
}
public void Uninitialize(InitializationEngine context)
{
}
}
Nice! I hadn't seen the IAvailableSettingsRepository interface before. That's good to know.
Hi,
I need to apply page type restriction to root page structure.My cms site page root structure look like this:
- Root
-The Table
-Home
-Page 1
-Page 2
-Page 3
I want to restrict Page 1,page 2 with same page type and page 3 with another page type.Is it possible to implement in cms.
Thanks