How to get pagetype’s AvailablePageTypes programatically?



Find page type’s available types

IAvailablePageTypes availablePageTypes = ServiceLocator.Current.GetInstance<IAvailablePageTypes>();
AvailableSetting setting = availablePageTypes.GetSetting(this.Name);
IList<string> allowedPageTypeNames = setting.AllowedPageTypeNames;

If you need more information about your available Page Types you can do:

PageTypeRepository repository = ServiceLocator.Current.GetInstance<PageTypeRepository>();
IEnumerable<PageType> availablePageTypes = allowedPageTypeNames.Select(name => repository.Load(name));

You have to use include property not includeon property on your page type, otherwise you will not be able to get any result from GetSetting method.


Happy Coding! 😇