Try our conversational search powered by Generative AI!

Trouble with AvailableContentTypesAttribute ExcludeOn/IncludeOn


I'm copying some core features of a site we built a few years ago to a new site and came across an unintentional content type restriction that's not letting me create a Login page. When I try to add a Login page, the only page types available are "Settings Page" and "Template Start Page". Here are the page types/models involved:

[AvailableContentTypes(ExcludeOn = new [] {typeof(SitePageData)})]
public class StartPage : SitePageData

[AvailableContentTypes(IncludeOn = new[] { typeof(StartPage) })]
public class TemplateStartPage : SitePageData

[AvailableContentTypes(Availability.Specific, IncludeOn = new[] { typeof(StartPage) })]
public class SettingsPage : PageData

public class LoginPage : SitePageData

I don't know why SettingsPage specifies Availability.Specific. What I think the goal was supposed to be is, a StartPage can only be a child of the Root page, and TemplateStartPage and SettingsPage can only be a child of StartPage. If I remove the attribute from StartPage LoginPage and all the other page types become available under it. But I don't understand why it's behaving this way because the description of ExcludeOn is, "Will exclude the typed page from the list of available ContentType for the specified typed pages. I read that as, "Will exclude StartPage from the list of available page types under SitePageDatas", but I seem to be misunderstanding it. I'm getting the same results in 11.14.2 as 9.12.2.

Mar 04, 2020 1:12

I find the naming (of the attribute properties) rather confusing, but assuming that you have no other requirements, you might want to revert it, so 

[AvailableContentTypes(Include = new [] {typeof(TemplateStartPage), typeof(SettingsPage), typeof(LoginPage)})]
public class StartPage : SitePageData

Mar 04, 2020 9:55
* 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.