To be able for each language versions of an item to have their own renderings in our Sitecore instance version 7.2, the __Renderings field shared option was set to false. This is not Sitecore Best Practice, but this is how it was solved. When migrating the content to Sitecore 8.2 I wrote a Power Shell script to migrate the rendering settings to the new __Final Rendering field.
Our setup uses Language Fallback and all languages are configured to fallback on the EN language. Even the __Renderings field is Language Fallback enabled.
First I took a copy of the SC72 environment to a new instance to avoid working with the live content. Then I installed the excellent PowerShell for Sitecore plugin and pasted the following code in the ISE interface.
These are the steps in details:
$rootPath = "master:\content\SITE\Home" $emptyRendering = @" <r xmlns:p="p" xmlns:s="s" p:p="1" /> "@ # First copy EN renderings to the Final Renderings field to gain Language Fallback on the other languages $items = (Get-Item -Path $rootPath -Version * -Language en) + (Get-ChildItem -Path $rootPath -recurse -Version * -Language en) ForEach ($item in $items) { $Renderings = $item."__Renderings" if($Renderings -ne $null) { $item."__Final Renderings" = $Renderings Write-Host "Setting Final Renderings for item '$($item.ID)' language '$($item.Language)'" } } # Then copy language renderings to the Final Renderings field on the language versions in case it differ from the EN version $items = Get-ChildItem -WithParent -Path $rootPath -recurse -Version * -Language da-DK, de-AT, de-CH, de-DE, en-AU, en-GB, en-US, es-ES, fi-FI, fr-BE, fr-CH, fr-FR, it-IT, ko-KR, nb-NO, nl-BE, nl-NL, pt-BR, sv-SE, zh-CN ForEach ($item in $items) { Reset-ItemField -Item $Item -Name "__Final Renderings" -IncludeStandardFields # No need if first time to run $ENItem = Get-Item master: -ID $item.ID -Language en if($ENItem -ne $null) { $ENrenderings = $ENitem."__Renderings" } $Renderings = $item."__Renderings" if($Renderings -ne $null) { if($Renderings -ne $ENrenderings) { $item."__Final Renderings" = $Renderings Write-Host "Setting Final Renderings for item '$($item.ID)' language '$($item.Language)'" } if($Renderings -eq $emptyRendering) { Reset-ItemField -Item $item -Name "__Final Renderings" -IncludeStandardFields Write-Host "Reset Final Renderings for item '$($item.ID)' language '$($item.Language)'" } } }
The script took about 1 hour to execute because of the large amount of content. The I exported all content by creating a SC package and imported it to the new SC82 instance. The media was serialized and reverted on the SC82 instance. Finally I run this clean up script in the SC82 environment to reset the language specific renderings on the EN item.
$rootPath = "master:\content\SITE\Home" # Reset the Renderings Field on the EN version $items = Get-ChildItem -WithParent -Path $rootPath -recurse -Version * -Language en ForEach ($item in $items) { Reset-ItemField -Item $item -Name "__Final Renderings" -IncludeStandardFields }
RRS feed