Code snippet to modify EPiServer pagetype definitions programmatically.
Few days back, I was assigned a project to amend an already created site and enable globalization on it. So I started by enabling globalization in EPiServer admin mode. Once done, the next task was to go to EPiServer edit mode and make “unique value per language” checked for all the properties. There are too many pagetypes that requires changes, so i decided to write a small code that does this for me .
//Get All the pageTypes
PageTypeCollection pageTypeCollection = PageType.List();
foreach (var pagetype in pageTypeCollection)
{
//get all the properties on pagetype
PageDefinitionCollection pageDefinitionCollection = pagetype.Definitions;
foreach (var pageDefinition in pageDefinitionCollection)
{
//Enable globalization and save
pageDefinition.LanguageSpecific = true;
pageDefinition.Save();
}
}
Thankz :)
Nice tip. Thanks for sharing.