Views: 3621
Number of votes: 4
Average rating:

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 Smile.

//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();

}

}

May 01, 2011

olga.bjorklund
(By olga.bjorklund, 5/2/2011 12:37:22 PM)

Thankz :)

Tamim Khan
(By Tamim Khan, 5/3/2011 1:36:48 PM)

Nice tip. Thanks for sharing.

Please login to comment.