Thursday 11 September 2014

Get all Page Types in EPiServer

To get all page types in Episerver, use the following code

using EPiServer.ServiceLocation;
using EPiServer.DataAbstraction;

var repository = ServiceLocator.Current.GetInstance<PageTypeRepository>();
var pageTypes = repository.List();

For older versions of Episerver if the above code doesn't work, use the following code.
Note: This function has been obsolete in latest versions of Episerver, but still works.

var pageTypes = EPiServer.DataAbstraction.PageType.List();

About the Author

Adnan Zameer, Lead Developer at Optimizley UK, is a certified Microsoft professional, specializing in web app architecture. His expertise includes Optimizley CMS and Azure, showcasing proficiency in crafting robust and efficient solutions.

1 comment :