I have a scenario where I have to enable the fallback for a template and on some particular scenarios I have to show the language versions only if it has that particular version. Ex: If it has a non english version show that version only in that language(no fall back) Item.Versions.count>0 returns true if I set Enable fall back to true. Is there a way I check if the version that is returned is fall back version speifically
3 Answers
You can call Item.IsFallback
, which returns true if the item in question is fallback item.
Source:
You can use property IsFallBack
. As per sitecore's documentation
The Sitecore.Data.Item class
The following properties have been added to the class:
OriginalLanguage – a property that returns the original language for the current item. If the item is not a fallback item, it returns the item.Language.
IsFallback – a property that returns true if the current item is a fallback item.
The Item class (in Sitecore.Kernel.dll, SC 8.1+) has a IsFallback property that will indicate if the item is a fallback item.
/// <summary>
/// Gets a value that indicates if the item is a fallback item.
/// </summary>
/// <value>
/// <c>true</c> if this item is a fallback item; otherwise, <c>false</c>.
/// </value>
public bool IsFallback
{
get
{
return this._originalLanguage != (Language) null;
}
}