using CopyPageData
Not a managed persistent instance.
Parameter name: component
Actual value was Telerik.Sitefinity.Pages.Model.PageNode.
var fluent = App.WorkWith().Page();
var mgrFluent = fluent.PageManager;
PageData sourcePageData =
mgrFluent.GetPageDataList().Where(pd => pd.Title == "myExistingPageDataTitle").FirstOrDefault();
// my MakeNewPage() creates a page that can display in the SF gui (a valid one)
// and is in a row of both sf_page_data and sf_page_node
PageData pd1 = MakeNewPage("theNewPageTitle4");
var ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
// in debug both sourcePageData and pd1 are populated w id etc from db
mgrFluent.CopyPageData(sourcePageData, pd1);
// same error if I use this overload
// mgrFluent.CopyPageData(sourcePageData, pd1, ci, ci, true);
How can I successfully use CopyPageData() ? Thanks.
Any progress on this? Solving this is becoming critical on our Gantt chart. :-)
Thanks.
Hello Phil,
You have to operate with the page node instead of using the PageData object.
var facade = App.WorkWith()
.Page(
new
Guid(pageId))
.Duplicate();
facade.SaveChanges();
var node = facade.Get();
SiteMapBase.Cache.Flush();
That worked. On my first try I got the error: Object references between two different object scopes are not allowed .... So I had to create the parent PageNode object and do the Duplicate method w the same App.WorkWith.Page object.
var mgr = App.WorkWith().Page(guidSourcePage);
PageNode parentPage =
mgr.PageManager.GetPageNodes().Where(pi => pi.Id == parentId).FirstOrDefault();
mgr.Duplicate().Do(
p =>
p.Title = newPageName;
p.UrlName = newPageName;
p.ShowInNavigation = true;
p.Parent = parentPage;
if (p.Page != null)
p.Page.Title = newPageName;
).SaveChanges();