0

I wonder when I copy final renderings, what does happen with the datasource, does this will be copy also datasource or not?

New-UsingBlock (New-Object Sitecore.Security.Accounts.UserSwitcher $elevatedUser) {
function Copy-FinalRenderings {
param(
    [Item]$baseLangItem,
    [Item]$newLangItem
)

if($baseLangItem.TemplateID -in $templateIds)
{
    $newLangItem.Editing.BeginEdit()
    $newLangItem.Fields["__Final Renderings"].Value = $baseLangItem.Fields["__Final Renderings"].Value
    $newLangItem.Editing.EndEdit()
}
}
2
  • Can you please add more details to your questions? What kind of issues you are getting? May 25 at 7:03
  • Is datasource copied to with final renderings? May 25 at 7:12

2 Answers 2

2

You are copying just a field in an item. This will not copy other items, like related datasources.

However, the relationship to the datasource items will remain as this is based on guids inside the final renderings field.

I think based on your code sample we can assume you are copying final renderings between language versions. In that case, the datasource relation will be fine. It will still point towards the original datasource but Sitecore will take the context language when rendering it.

2
  • Does this means the content will remain in only original version of data source and content will not be visible? May 25 at 14:13
  • No new versions will be created. If you have language fallback enabled, that is not an issue. Otherwise the datasources will not be found indeed.
    – Gatogordo
    May 25 at 15:26
2

Along with the answer given by @Gatogordo, want to add this like If you want the list of data sources used in your rendering, then you can use the following Powershell Command, which will give you the output of the data source used.

$defaultLayout = Get-LayoutDevice -Default

$rootItem = Get-Item -Path "master:" -ID "<your-item-id>"

Get-Rendering -Item $rootItem -Device $defaultLayout -FinalLayout | Select-Object -Property DataSource

Then you can copy those items into your new location.

1
  • The problem is with this the content is not copied to newly created page item language version May 25 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.