I'm attempting to use Sitecore Powershell Extensions to automate Step 2 of the following upgrade guide for a Sitecore accelerator known as SCORE:
https://brainjocks.atlassian.net/wiki/spaces/SDD/pages/390594792/Add+New+Placeholder+Settings
In the step, a variety of new placeholder settings are added to the Presentation Details of each page's __Standard Values on the Sitecore installation. I've found several resources on how to add a rendering definition item to a layout but no resources on how to add a placeholder. Here is a snippet of what I have so far:
#define placeholders to add
$facetPlaceholder = "<p uid=`"{1E5FCA45-4AF1-40AB-9479-FE9AE4172DB5}`" key=`"Facets`" md=`"$tenantCopyPath/Facets`" />"
$searchResultViewsPlaceholder = "<p uid=`"{5137EC9B-4DC0-464B-A522-6FB1EE5362E9}`" key=`"Search Result Views`" md=`"$tenantCopyPath/Search Result Views`" />"
$slickSliderPlaceholder = "<p uid=`"{F2B4B648-5BCF-4556-9630-467F2A710B98}`" key=`"Slick Slider`" md=`"$tenantCopyPath/Slick Slider`" />"
if ($pageTemplatesExist) {
$children = Get-ChildItem -Path $pageTemplatePath
foreach ($child in $children) {
$childPath = $child.Paths.Path
$standardValues = Get-ChildItem -Path $childPath
if ($standardValues.length -ne 0) {
$renderingsField = $standardValues.Fields["__Renderings"].ToString()
$testXML = [xml]$renderingsField
if (-not ($renderingsField -contains 'Facets')) {
$standardValues.Editing.BeginEdit()
$standardValues.Editing.EndEdit()
}
else {
Write-Host "Placeholder setting already exists for Facets at item: $($standardValues.Paths.Path) "
}
if (-not ($renderingsField -contains 'Search Result Views')) {
$standardValues.Editing.BeginEdit()
$standardValues.Editing.EndEdit()
}
else {
Write-Host "Placeholder setting already exists for Search Result Views at item: $($standardValues.Paths.Path) "
}
if (-not ($renderingsField -contains 'Slick Slider')) {
$standardValues.Editing.BeginEdit()
$standardValues.Editing.EndEdit()
}
else {
Write-Host "Placeholder setting already exists for Slick Slider at item: $($standardValues.Paths.Path) "
}
}
else {
Write-Host "No standard values template for page at path: $childPath"
}
}
}
else {
Write-Host "No page templates found for $tenant found at path: $pageTemplatePath"
}
My current idea is to manually modify the __Renderings standard field. I was going to grab the string version of the __Renderings field, inject my new placeholder markup where needed(possibly first converting this string to XML to make my modifications easier although I was having trouble getting the __Renderings read into an xml variable), then reassigning the original __Renderings field value to my new modified version. Is there a more straightforward way to accomplish this task without manually manipulating the __Renderings field? Thanks for the assistance!