There might be scenario, where
- remove a rendering from list of pages/Tree
- remove broken rendering from Tree
Above we can achieve using Sitecore PowerShell script
$pageTemplateId = "{4A990Q43-71FD-4DAC-8865-5ABAAA13R911}"
$startPath = "master:/sitecore/content/YourSiteNode/Home/"
$useFinalLayout = $True
$useSharedLayout = $True
$rootItem = Get-ChildItem -Path $startPath -recurse | Where-Object { $_."TemplateID" -eq $pageTemplateId };
if($rootItem -ne $null) {
foreach($item in $rootItem) {
$renderings = Get-Rendering -Item $item -Placeholder "/header/primary-menu" -Device (Get-LayoutDevice "Default") -FinalLayout:$useFinalLayout
foreach($rendering in $renderings) {
$renderingItem = Get-Item -Path $rendering.ItemID
if($renderingItem.Name -eq "YourRenderingName") {
Remove-Rendering -Item $item -Instance $rendering -Device (Get-LayoutDevice "Default") -FinalLayout:$useFinalLayout
Write-Host $item.Name
}
}
}
}
No comments:
Post a Comment