You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create in 'Site A' a page 'ParentPage' with child page 'ChildPage 1'
Create 'Site B'
Add a page for 'Site B' by copying 'ChildPage 1'
Copy page for 'ChildPage 1' is creaed with success but it does not show up in the page overview page listing
Expected result
The copied page shows up in page overview
Proposed solution
In Piranha.Core, Piranha.Services.PageService, method CopyAsync, the returned model should have its ParentId property set to null.
Otherwise this ParentId remains set to a page in the source site, which might not exist in the destination site (if the destination site is different then the source site) -> this causes the page to not show up in the page overview
An extra improvement to this proposed fix is to make it in Piranha.Manager.PageService, in methods Copy and CopyRelative
In method Copy just check if the original.SiteId is the same as parameter siteId
Proposed code fix
`
public async Task Copy(Guid sourceId, Guid siteId)
{
var original = await _api.Pages.GetByIdAsync(sourceId);
if (original != null)
{
var page = await _api.Pages.CopyAsync(original);
page.SiteId = siteId;
page.SortOrder = (await _api.Sites.GetSitemapAsync(page.SiteId, false)).Count;
if (original.SiteId != siteId)
{
page.ParentId = null;
}
// Perform manager init
await _factory.InitDynamicManagerAsync(page,
App.PageTypes.GetById(page.TypeId));
return Transform(page, false);
}
return null;
}
public async Task<PageEditModel> CopyRelative(Guid sourceId, Guid pageId, bool after)
{
var relative = await _api.Pages.GetByIdAsync<PageInfo>(pageId);
if (relative != null)
{
var original = await _api.Pages.GetByIdAsync(sourceId);
if (original != null)
{
var page = await _api.Pages.CopyAsync(original);
page.SiteId = relative.SiteId;
page.ParentId = after ? relative.ParentId : relative.Id;
page.SortOrder = after ? relative.SortOrder + 1 : 0;
if (original.SiteId != siteId)
{
page.ParentId = null;
}
// Perform manager init
await _factory.InitDynamicManagerAsync(page,
App.PageTypes.GetById(page.TypeId));
return Transform(page, false);
}
}
return null;
}`
The text was updated successfully, but these errors were encountered:
Steps to reproduce
Expected result
The copied page shows up in page overview
Proposed solution
In Piranha.Core, Piranha.Services.PageService, method CopyAsync, the returned model should have its ParentId property set to null.
Otherwise this ParentId remains set to a page in the source site, which might not exist in the destination site (if the destination site is different then the source site) -> this causes the page to not show up in the page overview
An extra improvement to this proposed fix is to make it in Piranha.Manager.PageService, in methods Copy and CopyRelative
In method Copy just check if the original.SiteId is the same as parameter siteId
Proposed code fix
`
public async Task Copy(Guid sourceId, Guid siteId)
{
var original = await _api.Pages.GetByIdAsync(sourceId);
The text was updated successfully, but these errors were encountered: