When Migrating sitecore 8 content to sitecore 9 then content are not rendered in sitecore 9

Hi,

If you are migrating content from sitecore 8 to sitecore 9 by using the sitecore packages then you may face the issue that your content is not rendered in sietcore 9 and it can be because of below reason.

If you are using external dynamic placeholder in sitecore 8 then you can face this issue because In sitecore 9, Dynamic place holder is out of the box with sitecore 9, and the way that sitecore 9 dynamic place holder is building the id for the placeholder is bit different than sitecore 8 placeholder, sitecore 9 is having the different format for the id.

sitecore 8 format for place holder id-

Sitecore 9 format for place holder id-

If you have noticed in the above images , Sitecore 9 is having curly braces with the ids and it may case that you can not rendered your content.

So if you are facing similar kind of issue then you can use below powersghell script to update the correct format of id for the existing content coming from sitecore 8.

1- Script to Update the ID format in all the templates for shared Layout-

# specify your path here. It is most likely be page templates and page content
$startPath = "/sitecore/templates"
$loopCounter=0
Get-ChildItem -Path $startPath -Version * -Recurse | ForEach-Object {
$item = $_;

Get-Rendering -Item $_ | ForEach-Object {
$rendering = $_;
$matches = [regex]::Matches($_.Placeholder,'(_[0-9a-fA-F]{8}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{12})')

if ($matches.Success) {
Write-Host "Match found in item - [$($item.Paths.FullPath)]"
Write-Host "Old Placeholder - [$($rendering.Placeholder)]"

$newPlaceholder = $rendering.Placeholder

$matches | ForEach-Object {
$renderingId = $_.Value
$newPlaceholder = $newPlaceholder.Replace($renderingId, "{$($renderingId.ToUpper())}-0")
}

$newPlaceholder = $newPlaceholder.Replace('{_', "-{")
Write-Host "New Placeholder - [$($newPlaceholder)]"

# comment following 2 lines if you don't want to do replacement, but want to have log of upcoming placeholder changes
$rendering.Placeholder = $newPlaceholder
Set-Rendering -Item $item -Instance $rendering
}
else
{
Write-Host "Record Not Matched for item number $loopCounter"
}
$loopCounter++
}
}

2- Script to Update the ID format in all the templates for final Layout-

# specify your path here. It is most likely be page templates and page content
$startPath = "/sitecore/templates"
$loopCounter=0
Get-ChildItem -Path $startPath -Version * -Recurse | ForEach-Object {
$item = $_;

Get-Rendering -Item $_ -FinalLayout | ForEach-Object {
$rendering = $_;
$matches = [regex]::Matches($_.Placeholder,'(_[0-9a-fA-F]{8}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{12})')

if ($matches.Success) {
Write-Host "Match found in item - [$($item.Paths.FullPath)]"
Write-Host "Old Placeholder - [$($rendering.Placeholder)]"

$newPlaceholder = $rendering.Placeholder

$matches | ForEach-Object {
$renderingId = $_.Value
$newPlaceholder = $newPlaceholder.Replace($renderingId, "{$($renderingId.ToUpper())}-0")
}

$newPlaceholder = $newPlaceholder.Replace('{_', "-{")
Write-Host "New Placeholder - [$($newPlaceholder)]"

# comment following 2 lines if you don't want to do replacement, but want to have log of upcoming placeholder changes
$rendering.Placeholder = $newPlaceholder
Set-Rendering -Item $item -Instance $rendering -FinalLayout
}
else
{
Write-Host "Record Not Matched for item number $loopCounter"
}
$loopCounter++
}
}

 

3-Script to Update the ID format in all the Contents for shared Layout-

# specify your path here. It is most likely be page templates and page content
$startPath = "/sitecore/content"
$loopCounter=0
Get-ChildItem -Path $startPath -Language * -Version * -Recurse | ForEach-Object {
$item = $_;

Get-Rendering -Item $_ | ForEach-Object {
$rendering = $_;
$matches = [regex]::Matches($_.Placeholder,'(_[0-9a-fA-F]{8}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{12})')

if ($matches.Success) {
Write-Host "Match found in item - [$($item.Paths.FullPath)]"
Write-Host "Old Placeholder - [$($rendering.Placeholder)]"

$newPlaceholder = $rendering.Placeholder

$matches | ForEach-Object {
$renderingId = $_.Value
$newPlaceholder = $newPlaceholder.Replace($renderingId, "{$($renderingId.ToUpper())}-0")
}

$newPlaceholder = $newPlaceholder.Replace('{_', "-{")
Write-Host "New Placeholder - [$($newPlaceholder)]"

# comment following 2 lines if you don't want to do replacement, but want to have log of upcoming placeholder changes
$rendering.Placeholder = $newPlaceholder
Set-Rendering -Item $item -Instance $rendering
}
else
{
Write-Host "Record Not Matched for item number $loopCounter"
}
$loopCounter++
}
}

 

4- Script to Update the ID format in all the Contents for Final Layout-

# specify your path here. It is most likely be page templates and page content
$startPath = "/sitecore/content"
$loopCounter=0
Get-ChildItem -Path $startPath -Language * -Version * -Recurse | ForEach-Object {
$item = $_;

Get-Rendering -Item $_ -FinalLayout | ForEach-Object {
$rendering = $_;
$matches = [regex]::Matches($_.Placeholder,'(_[0-9a-fA-F]{8}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{4}[-][0-9a-fA-F]{12})')

if ($matches.Success) {
Write-Host "Match found in item - [$($item.Paths.FullPath)]"
Write-Host "Old Placeholder - [$($rendering.Placeholder)]"

$newPlaceholder = $rendering.Placeholder

$matches | ForEach-Object {
$renderingId = $_.Value
$newPlaceholder = $newPlaceholder.Replace($renderingId, "{$($renderingId.ToUpper())}-0")
}

$newPlaceholder = $newPlaceholder.Replace('{_', "-{")
Write-Host "New Placeholder - [$($newPlaceholder)]"

# comment following 2 lines if you don't want to do replacement, but want to have log of upcoming placeholder changes
$rendering.Placeholder = $newPlaceholder
Set-Rendering -Item $item -Instance $rendering -FinalLayout
}
else
{
Write-Host "Record Not Matched for item number $loopCounter"
}
$loopCounter++
}
}