简体   繁体   中英

Is it possible to restrict an instance of a pagetype in EpiServer?

Under Start I want the user to only have the possibility to create one instance of my EmailTemplatePage pagetype. Is it possible?

You can use the AvailableContentTypes attribute on your start page type:

[ContentType]
[AvailableContentTypes(Availability.Specific, Include = new [] { typeof(EmailTemplatePage) })]
public class StartPage : PageData
{
}

A simple solution could be that you create the single page, and then set "Available in edit mode" to false on the page type. Then it will not be possible for editors to create another page (but they can still make a copy of the existing page).

If your requirement is that an editor should be able to create just one page of a specific page type in a specific part of the page tree, you would need to create a custom validation when the page is saved.

Something like this: https://blog.wsol.com/improving-episervers-content-editing-experience-through-validation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM