Creating pages by code

Vote:
 
hi I use EPiServer 4.51 and multi language module. I've created a page programmatically (see below), i look at the page in edit mode on the swedish tab, press the "Save and publish" button. The page is saved but the information on the common tab is cleared. This behaviour isn't displayed when a create a page manually, and is kind of strange. Futher when I set properties for several language as Mainbody___SV and Mainbody___EN, EPiServer creates two or more pages, but only one page id is returned by the "Save"-method in EPFactory, one for each language that has a properties that have been set. regs Stefan //myParentPage is the id of the page parent //myPageTypeName is the name of the page type for the new page EPiServer.Core.PageData newPage = Global.EPDataFactory.GetDefaultPageData(myParentPage, myPageTypeName); newPage.LanguageID = "SV"; newPage.PageName = "-"; PropertyData pageProp; //myProperties is an array with the PropertyData for (int i = 0; i < myProperties.Count; i++) { pageProp = (PropertyData) myProperties[i]; if (newPage.Property.Exists (pageProp.Name)) { newPage.Property[pageProp.Name].Value = pageProp.Value; } } EPiServer.Global.EPDataFactory.Save (newPage, EPiServer.DataAccess.SaveAction.Save); return true;
#12422
Nov 02, 2005 17:15
Vote:
 
It seems to work if I do a save of the page and set LoadRawPageData to true on the returned page ref. After that try to set the values. regs //Stefan newPage.LanguageID = "SV"; newPage.PageName = "-"; pageRef = EPiServer.Global.EPDataFactory.Save (newPage, EPiServer.DataAccess.SaveAction.Save); pageRef.LoadRawPageData = true; newPage = EPiServer.Global.EPDataFactory.GetPage (pageRef); PropertyData pageProp; for (int i = 0; i < myProperties.Count; i++) { pageProp = (PropertyData) myProperties[i]; if (newPage.Property.Exists (pageProp.Name)) { newPage.Property[pageProp.Name].Value = pageProp.Value; } } EPiServer.Global.EPDataFactory.Save (newPage, EPiServer.DataAccess.SaveAction.Save);
#14238
Nov 03, 2005 17:04
* 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.