4

Presently I'm working on Sitecore 8.1 Update-1.

We have enabled Item-level language fallback on shell and website as suggested on Configure language fallback - Sitecore Documentation.

It seems after this we need to go to each template and enable the Item-level language fallback. It involves generating __Standard Values if its not there and then manually change the flag for item fallback [screenshot below].

Enable Item Fallback

I have found this Sitecore PowerShell script on this blog post which switches the Item-level fallback flag but here I will also require to generate __Standard Values on template.

(Get-Item master: -Query "/sitecore/templates//*[@@name='__Standard Values']")| ForEach-Object {

    $_.Editing.BeginEdit()
    $_.Fields["__Enable item fallback"].Value = "1";
    $_.Editing.EndEdit()
}

I'm trying on optimizing this process since same process has to be followed on multiple environments. How one can go for this with minimum impact/steps?

1
  • In regard to your update - changing standard items that come with Sitecore is a bad practice. Not only can you get problems when upgrading Sitecore version in the future, but also you're implementing item-level fallback for literally all items in Sitecore, including templates, layouts, etc. This may lead to unnecessary overhead, and even obscure errors, as changing that default value definitely has not been tested by Sitecore. Commented Dec 1, 2016 at 16:25

3 Answers 3

7

I think that scripting this task is the way to go in your case.

Note that the script below doesn't update all templates' standard values, but only for templates under User Defined. If that doesn't suit you, feel free to adjust the path.

$templates =
    Get-ChildItem 'master:/sitecore/templates/User Defined' -Recurse |
    ? { $_.TemplateId -eq '{AB86861A-6030-46C5-B394-E8F99E8B87DB}' }

foreach($template in $templates) {

    $standardValuesPath = "master:$($template.FullPath)/__Standard Values"

    if(Test-Path $standardValuesPath) {
        $standardValues = Get-Item $standardValuesPath
    } else {
        $standardValues = New-Item -Path $standardValuesPath -Type $template.ID
        $template.'__Standard values' = $standardValues.ID
    }

    $standardValues.'__Enable item fallback' = $true
}
4
  • I have updated my question now...
    – Harsh Baid
    Commented Dec 1, 2016 at 16:23
  • @HarshBaid Are you changing your question to something else now? Or would you like me to update something in my answer? Commented Dec 1, 2016 at 16:25
  • Question is still same.. just posted that one possibility other than PowerShell Scripting ;) but I think your point is correct about not modifying default Sitecore system items.
    – Harsh Baid
    Commented Dec 1, 2016 at 17:00
  • @Dmytro the PowerShell script is working perfectly fine. Thanks a lot.
    – Harsh Baid
    Commented Dec 1, 2016 at 20:34
3

I face similar situation before.

I approached this way:

As I inherit all my templates from "content" template, which is a custom empty template inherited from sitecore standard Template.

For me enabling item level fallback on "content" template __standardValues worked.

2
  • 1
    It does work. A great find! I wasn't aware of field-level inheritance between standard values. Commented Dec 1, 2016 at 17:35
  • 1
    Thanks @Dheeraj since I didn't wanted to introduce new template and anyways had to use PowerShell script one or other way for bulk operation to either update Fallback Field or Base Template Field ( if I had used concept in your answer) . I have used the PowerShell script provided by Dmytro for this instance.
    – Harsh Baid
    Commented Dec 1, 2016 at 20:43
1

I'm posting this as one of the possibility, To update the Default Value on Sitecore field definition of __Enable item fallback located here - /sitecore/templates/System/Templates/Sections/Advanced/Advanced/__Enable item fallback [screenshot below] as I wanted Item-level fallback to happen for all items:

__Enable item fallback

Note: It is Sitecore best practice that we better not update system templates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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