create page programmatically in more than 1 language

Vote:
 

I want to create  a page in 2 different language programmatically, but however it creates only 1 page, below is the code i am using

//adding english cunard page
myPage.PageName = dataToSave.ProductPageDetails.ProductName;
myPage.URLSegment = EPiServer.Web.UrlSegment.CreateUrlSegment(myPage);






myPage.PageName = dataToSave.ProductPageDetails.ProductName;
myPage.URLSegment = EPiServer.Web.UrlSegment.CreateUrlSegment(myPage);

//create page in english language
myPage = DataFactory.Instance.CreateLanguageBranch(myPage.PageLink, new LanguageSelector("en-cunard"));
DataFactory.Instance.Save(myPage, EPiServer.DataAccess.SaveAction.CheckIn, EPiServer.Security.AccessLevel.NoAccess);

 

//create page in german language

myPage  = DataFactory.Instance.CreateLanguageBranch(myPage.PageLink, new lLnguageSelector("de-cunard"));

DataFactory.Instance.Save(myPage, EPiServer.DataAccess.SaveAction.CheckIn, EPiServer.Security.AccessLevel.NoAccess);

 

In above code it creates page in 1 languge only which is the last one (de-cunard).

#72886
Jul 02, 2013 12:10
Vote:
 

Haven't it tried by myself, but can you try to capture result from first .Save() and then pass that value to second .CreateLanguageBranch() method?

Creating new language branch programmatically should be straight forward. http://tedgustaf.com/blog/2010/5/create-a-new-page-language-branch-programmatically-in-episerver/

#72907
Jul 02, 2013 16:34
Vote:
 

Thanks a lot Valdis, It solves my problem.

#73543
Jul 26, 2013 15:03
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.