Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

AvailablePageTypes includes all derived pagetypes as well

Vote:
 

Consider this scenario:

[AvailablePageTypes(Availability.Specific, Include = new Type[] {typeof(StandardPage), typeof(ContainerPage), typeof(MapPage))]
public class MyPage : PageData

Then consider that you have 20 pagetypes which inherits StandardPage because they all have H1, MainIntro, MainBody, PageImage, etc.

Is there a way to allow ONLY StandardPage to be created under MyPage? Like it used to work in PageTypeBuilder :)

Except of course to explicitly list all those 20 pagetypes on every pagetype.

#63533
Nov 21, 2012 15:53
Vote:
 

I would suggest not having your pages derive from Standardpage(PageType).  I would create an abstract class called BasePageType and derive your pagetypes from that.  Then you would have a standardPage(PageType) derive that that with no properties in that.

public abstract class PageTypeBase : PageData
{
[Display(Order = 1, Name = "Page Title", Description = "Used as the headline on each page"), CultureSpecific(true)]
        public virtual string PageTitle { get; set; }

        [Display(Order = 500, Name = "Main Body", Description = "The page text"), BackingType(typeof(PropertyXhtmlString)), CultureSpecific]
        public virtual XhtmlString MainBody { get; set; }
}

[ContentType(DisplayName = "Standard Page", GUID = "0b97d3d3-648f-4faf-839c-49e93a2b1b15", Order = 1)]
    public class Standard : PageTypeBase
    {
    }

    

#63544
Nov 21, 2012 18:48
Vote:
 

Hi Thomas

If I understand your problem correctly you are probably looking to use IncludeOn which allows you to specify which parent page types you want your page to be allowed under.

See my blog post for an explanation of this and also a comparison to PTB: http://www.david-tec.com/2012/06/Comparing-PageTypeBuilder-and-EPiServer-7-Preview-typed-pages-part-2-of-3/

David

#63546
Edited, Nov 21, 2012 20:02
Vote:
 

Thanks for both your comments. I had already considered both alternatives, and for now my workaround is Alternative 1, move the properties to an abstract baseclass and change the inheritance. However, I can think of a couple of reasons why that's not a good idea in the longer run.

The IncludeOn works of course, only that I would prefer to put the pagetype availability settings in one place, on the parent level. 

I guess I'm saying I would like to see the Availability.Specific to really mean SPECIFIC page types, and perhaps an Availability.InheritedFrom enum for how it works today.

#63548
Nov 21, 2012 21:34
Vote:
 

I am not sure I understand.  You put the Availability on the Sepcific PageType.  You just leave the abstract class alone. What are you seeing when you put the availablity on the pagetype. 

#63555
Nov 22, 2012 3:59
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.