I have a sharepoint site that got migrated from SP 2010 to SP 2013. The webparts in the pages uses layouts like center left, center right, center etc. With SP 2013, they have changed the layout structure into zone 1,2,3,4 to support responsive design.
Now, I am writing a power-shell script to loop through all the webparts in my site collection and I need to find the layout of the webparts so that I can change them into zones with zone index.
The code I have to loop through the webparts, i have the following:
function enumerateWebParts($Url) {
$site = new-object Microsoft.SharePoint.SPSite $Url
foreach($web in $site.AllWebs) {
if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) {
$pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$pages = $pWeb.PagesList
foreach ($item in $pages.Items) {
$fileUrl = $webUrl + "/" + $item.File.Url;
$manager=$item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared);
$wps = $manager.webparts;
#Which object should i select here?? Something like layout?
#$wps | select-object @{Expression={$pWeb.Layout};
}
}
}
}
$Call = enumerateWebParts("http://mywebsiteURL/siteCollection")
How would I select the layout zone? If I am able to read their layout zone, then I can write series of if else question to change their layout zone (like from center-right to zone-2)