November 25, 2016

Tips about the fallback in Sitecore

Tip number 1

Problem: The fallback is disabled by default in the item:save events.
Tip: You can use the following code:
using(new FallbackDisabler(FallbackStates.Default))
{  
   db.GetItem()
   ...
}

Tip number 2

Problem: The fallback is not active in the scheduled tasks.
Tip: In the FieldFallback_00.config, you need to add the site 'scheduler' in the 'sites' tag.

Tip number 3

Problem: When you use the Link database to retrieve an item, you have a ItemLink (the link between the 2 objects). If you do a .GetSourceItem() on this ItemLink, the fallback is not applied.
Tip: You need to retrieve this item with the standard method: db.GetItem(itemId).

Tip number 4

Problem: The ancestor fallback didn't work in the other languages.
Tip: To enable the ancestor fallback on a field, you need to select the template's field and check the EnableAncestorFallback checkbox. But, be careful because this checkbox is not shared. So two solutions here: check it in every languages or change this checkbox to shared.

1 comment: