SharePoint 2010: This page is not using a valid page layout
SharePoint 2010 I have an enterprise wiki site, that I exported and imported from one farm to another. However, I exported it form a site collection root site, to a sub site in another site collection. When I browse to any page that was created with the Enterprise wiki template, I get the error:
This page is not using a valid page layout. To correct the problem, edit page settings and select a valid page layout."开发者_Go百科
The page layout is showing as Basic Page. And works ok for new pages created. How can I fix the page layout, that is in the existing pages?
Any thoughts?
Turns out it's a bug. If you import a publishing site, the pages do not have the correct link to the page layout. No way to fix this through the UI. I had to use PowerShell.
I followed Mahesh's Blog to this MS Support article and used the Manage Content and Structure tool to change the Page Layout. Quite strange (this error seems to be a downstream error from a page that failed to upgrade from SharePoint 2007 and had a XsltListViewWebPart which had an invalid GroupBy setting).
Below is a simpler /similar version of the code in the link copied in case the original goes away (I've added notes about what needs to be changed)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
$web = Get-SPWeb -Identity "http://web/you/are/modifying"; #Change web that you're modifying on this line
$spPubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web);
$pages = $spPubWeb.PagesList;
foreach($item in $pages.Items)
{
$pubPage = [Microsoft.SharePoint.Publishing.PublishingPage]::GetPublishingPage($item)
$url = new-object Microsoft.SharePoint.SPFieldUrlValue($pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout].ToString())
if($url -ne $null)
{
if($url.Url -match 'NameOfPageLayout') #Change Page layout name on this line
{
$newurl = new-object Microsoft.SharePoint.SPFieldUrlValue("http://new/rootweb/_catalogs/masterpage/NewPageLayout.aspx, NewPageLayoutName") #Change URL and name on this line
$pubPage.Name
$pubPage.CheckOut()
$pubPage.ListItem[[Microsoft.SharePoint.Publishing.FieldId]::PageLayout] = $newurl
$pubPage.ListItem.UpdateOverwriteVersion()
$pubPage.ListItem.File.CheckIn("Fixed URL to page layout.", [Microsoft.SharePoint.SPCheckinType]::MajorCheckIn);
}
}
}
精彩评论