Create a new page language branch programmatically in EPiServer

This article describes how to create a new language branch programmatically for an existing page in EPiServer.

  • 21 May 2010
  • 0

Create language branch in code using the CreateLanguageBranch method

The following code sample illustrates how to create a new language branch for an existing page in EPiServer:

// Reference to the page we want to create a new language branch for
var pageLink = new PageReference(123);
 
// Create swedish language version
var newLanguageBranch = DataFactory.Instance.CreateLanguageBranch(
                        pageLink, 
                        new LanguageSelector("sv"));
 
// Set page name
newLanguageBranch.PageName = "Page in another language";
 
// Save the page regardless of current user permissions
DataFactory.Instance.Save(
   newLanguageBranch,
   SaveAction.Save,
   AccessLevel.NoAccess);