I am trying to retrieve these values found in the "final renderings" field:
p:after
and p:before
.
But I can't seem to find them anywhere. Is there a way to get them out?
The reason I need those, is I am taking some renderings, that are nested inside another "columns" rendering and pulling them out. Unfortunately this means they are getting placed differently than before, as the "columns" rendering has the p:after
placement set. I would like to transfer this from the "columns" rendering to the first nested rendering.
Simplified PowerShell script I am testing:
$rootItem = Get-Item master:"/content";
$renderings = @('{521F66ED-76BC-4C40-9D8D-9FC23145FC80}', # Container deck 3 column
'{8278046D-8762-4F1F-916C-07ECEC2EE9C7}') # Virksom 3 column deck
$defaultLayout = Get-LayoutDevice "Default"
foreach($renderingId in $renderings) {
$oldRendering = Get-Item -Path "master:" -ID $renderingId
Get-ChildItem $rootItem.FullPath -recurse -Language "da" | ForEach-Object {
$itemPath = $_.Paths.ContentPath
$sourceRenderings = Get-Rendering -Item $_ -Device $defaultLayout -FinalLayout | Where-Object { $_.ItemID -eq $renderingId -And -Not([string]::IsNullOrEmpty($_.Datasource)) }
if ($sourceRenderings -ne $null) {
foreach($sourceRendering in $sourceRenderings) {
$column1 = Get-Rendering -Item $_ -Device $defaultLayout -FinalLayout | Where-Object { $_.Placeholder -eq "/main/virksom-content/deck-column-1-$($sourceRendering.UniqueID)-0" }
foreach($col in $column1)
{
#tried to find it here
#Write-Host ($col| Format-List | Out-String)
#tried to find it here, probably the same as before
$finalLayoutField = $_.Fields[[Sitecore.FieldIDs]::FinalLayoutField]
$finalLayoutXml = [Sitecore.Data.Fields.LayoutField]::GetFieldValue($finalLayoutField)
$finalLayout = [Sitecore.Layouts.LayoutDefinition]::Parse($finalLayoutXml)
$renderings = $finalLayout.Devices[0].Renderings
Write-Host ($renderings| Format-List | Out-String)
#nothing in Dynamic Properties
#foreach($dynamicProperty in $col.DynamicProperties)
#{
#$propertyName = $dynamicProperty.ToString()
#$text = $dynamicProperty.Value
#Write-Host("$($propertyName) - $($text))");
#}
# new placeholder, that is no the old dynamic placeholder
$placeholder = $col.Placeholder
$placeholderLength = $placeholder.Length
$placeholderLastIndexOfSlash = $placeholder.LastIndexOf('/')
$placeholderAncestorPath = $placeholder.SubString(0, $placeholderLastIndexOfSlash)
#save the new placeholder
#but we need the p:after on the old "columns" component
# $col.Placeholder = $placeholderAncestorPath;
# Set-Rendering -Item $_ -Instance $col -FinalLayout;
#delete old rendering
#missing
}
}
}
}
}