Item Renderings
In this section we'll show how to manage item renderings.
List renderings
Example: The following demonstrates the use of Get-LayoutDevice and Get-Rendering to find all renderings on a page associated with the FinalLayout.
$defaultLayout = Get-LayoutDevice -Default
$rootItem = Get-Item -Path "master:" -ID "{961563FC-3445-4558-BF3A-06DF06BA6298}"
Get-Rendering -Item $rootItem -Device $defaultLayout -FinalLayoutUpdate rendering parameters
Example: The following demonstrates the use of Get-Rendering and Set-Rendering for updating values on templates.
$rendering = Get-Item -Path "master:\sitecore\layout\Sublayouts\Sample Sublayout"
$items = Get-ChildItem -Path "master:\sitecore\templates\Sample Item" -Recurse
foreach($item in $items) {
$renderingInstance = Get-Rendering -Item $_ -Rendering $rendering
if ($renderingInstance) {
Set-Rendering -Item $_ -Instance $renderingInstance -Parameter @{
"Lorem" = "Ipsum"
}
Write-Host "Updated $($_.Paths.FullPath)"
}
}Find pages using rendering
Example: The following demonstrates how to report on pages referencing the specified rendering.
Find renderings marked cacheable
Example: The following demonstrates how to report on which renderings are globally set to "Cacheable".
Find renderings with personalization
Example: The following demonstrates how to find renderings with a conditions node set on the item.
Disable cacheable setting on renderings
Example: The following demonstrates how to disable global caching on all renderings.
Move renderings between placeholders
Example: The following moves renderings from one placeholder to another. See this article for more details.
Remove datasource from rendering
Example: The following removes a datasource from a rendering on the FinalLayout.
Replace compatible rendering
Further Reading
Last updated