Sitecore PowerShell – Enable Item Level Language Fallback

The use case for this blog is to enable item-level fallback on all items based on any user-defined template (or based on any template located in a given folder).

Here are three steps you need to follow in order to set up the language fallback functionality in Sitecore:

  1. Enable site-level fallback in \Website\App_Config\Include\Sitecore.LanguageFallback.config.
  2. Specify the Fallback Language for the language items located in sitecore/system/Languages.
  3. Either enable item-level fallback or field-level fallback per your need.

To enable fallback for all items of a given template, just set it on the template’s __Standard Values.

fallback

However, when there are too many templates to deal with, this task can become very tedious, so we are going to automate this process and perform a batch update using Sitecore Powershell Extensions.

Here is my script:

Write-Host "Creating Standard Values items for:" -ForegroundColor green
$Items = Get-ChildItem master: -ID "{GUID of the templates folder}" -Recurse | Where-Object {$_.TemplateName -eq 'Template'-and `
                !$_.Children["__Standard Values"] }

foreach($Item in $Items)
{
    Write-Host $Item.Paths.Path
    $standardvalues = New-Item -Parent $Item -Name "__Standard Values" -type $Item.ID
    $Item.Editing.BeginEdit()
    $Item["__Standard values"] = $standardvalues.ID
    $Item.Editing.EndEdit()
}
Write-Host "Total number of items modified: " $Items.Count

Write-Host "Enabling Item Level Fallback for:" -ForegroundColor green
$Items = Get-ChildItem master: -ID "{ GUID of the templates folder }" -Recurse | Where-Object {$_.Name -eq '__Standard Values'-and `
                $_.'__Enable item fallback' -eq $false }
foreach($Item in $Items)
{
    $Item.'__Enable item fallback' = $true
    $Item.Paths.Path
}
Write-Host "Total number of items modified: " $Items.Count

The first half of the script finds all templates within the given folder (such as a “User Defined Templates” folder), and creates a __Standard Values item for the templates that don’t already have one. The second half of the script goes through all the __Standard Values items that don’t have Enable Item Fallback checked and set them to true.

The paths of all modified items are printed to the console:

Creating Standard Values items for:
 /sitecore/templates/User Defined/Public/Carousels/FeaturedItemsCarousel
 True
 /sitecore/templates/User Defined/Public/Carousels/RecognitionCarousel
 True
 /sitecore/templates/User Defined/Public/Carousels/TimelineCarousel
 True
  …
Total number of items modified:  39


Enabling Item Level Fallback for:
 /sitecore/templates/User Defined/Public/Careers/Statement Block/__Standard Values
 /sitecore/templates/User Defined/Public/Careers/Header Section/__Standard Values
 /sitecore/templates/User Defined/Public/Careers/Landing Hero Section/__Standard Values
  …
Total number of items modified:  227

 

Now you efficiently have all items based on the templates in that folder enabled for fallback. Please feel free to let me know your thoughts and suggestions. Thanks!

My Experience with the new Sitecore® Professional Developer Certification Exam (MVC)

I have just passed the new Sitecore® Professional Developer Certification exam today and I’d like to share some of my experience here. It’s a two-hour exam but you are likely to finish it in one hour or less. 70 multiple choice questions in total, no notes allowed. The exam questions are not very hard but they are very comprehensive. They cover all the topics (shown below) listed on the Exam Study Guide page, and the accompanied percentages are quite accurate. The Sample Questions on that Study Guide page were a big help on the exam, and so were the review questions at the end of each module in the training material.

Competencies % of Questions
API 6 %
Architecture 2 %
Creating and Editing Items 9 %
Development Environment 6 %
Fields and Field Types 9 %
Installation 2 %
Marketing 10 %
Media 2 %
Module Packages 2 %
Multi-Language 3 %
Publishing 6 %
Search 10 %
Security 6 %
Sitecore Documentation and Support 2 %
Templates 11 %
Versioning 2 %
Workflows 3 %
xManagement 9 %
TOTAL 100%

It’s been about four months since I first got on Sitecore. I was staffed on a Sitecore project after the first month of learning and now the project has just been completed. If you could fully focus on just preparing for the exam, one month of time should be enough, assuming you have some prerequisite knowledge in ASP.NET and MVC. Here are some of my personal experience and recommendations:

– Watch all the Sitecore® Experience Solution Developer eLearning training videos. This is the most helpful resource for the exam. Take notes and screenshots throughout the course because:

  1. The course expires after a few months and you won’t be able to come back to it.
  2. Reviewing the notes and screenshots when it gets close to the exam day proved to be very helpful to me. Many exam questions come directly from details that I have taken down in my notes.

– Complete all the labs in the Workbook PDFs that come with the training. The labs are very hands-on and well designed. I did the labs after I went through all the training videos, because:

  1. I couldn’t help but first cover all the aspects Sitecore has to offer; doing the corresponding lab right after each module slows me down.
  2. Many, many topics are covered in the training (and surely in the exam), and I tend to forget some knowledge that I’ve learned as I go along with the training. Starting the labs after completing all the training videos gives me another chance to refresh and enhance my memory. There were some exam questions that I was able to answer because I did the labs, coded in Visual Studio and configured in Sitecore.

– (Optional) Get on a real-life Sitecore project. I have heard talk that the old Web Form training was not super helpful in terms of practical usage, but that’s not the case with the new training. I got up to speed with the project development quite fast because I was prepared from the training. More than a few times I used my notes and the book mentioned below as reference to resolve the problems I had at hand. On the other hand, the project experience familiarized me with Sitecore development and thus I could fly though the labs later without much need to debug.

– (Optional) Read the Professional Sitecore 8 Development book by Phil Wicklund and Jason Wilkerson. This book should be read after you complete the training material (said from someone who didn’t – I read the book first), or else you might often get confused reading it. This book will help you more in your development experience than the certification exam; it includes some discussion and projects on topics such as Helix, Inversion of Control, Design Patterns, the Sitecore PowerShell extension etc. If all you have is the book and you don’t have access to the $1500 training, this free course, Sitecore® Developer Foundations, can get you started with some basic concepts.

I’m very happy to share my experience with the hope that it can help prepare you for the exam. I encourage you to write any feedback about your experience or questions about the exam. Good luck!