Here is a brief understanding of my scenario,
- Create a template with 2 unversioned fields
Sport
andAnimal
- Create an item based on this template in 2 languages English & Arabic
- For English language version fill both fields with "I am English"
- For
Arabian
, leaveAnimal
field empty, andSport
-> setArabian value
Result:
When one requests a page with Context
, language = Arabian
, Animal
field would show I am English
, whereas Sport
would have Arabian value
.
Hi Nikolay Mitikov, I have two field where unversioned is not marked as shown in above image. rest of you understanding is 100% correct. also i have not implemented any custom logic or have not used any extension that could trouble this. for arabic and english culture i am just using different url by sc_lang querystring or "ar" in url which sets context language that's all. below is my language switcher simple code:
public string ItemEnglishURL
{
get
{
return string.Concat(Helper.GetItemUrlByCulture(Sitecore.Context.Item, "en"), CurrentQueryString);
}
}
public string ItemArabicURL
{
get
{
return string.Concat(Helper.GetItemUrlByCulture(Sitecore.Context.Item, "ar"), CurrentQueryString);
}
}
public static string GetItemUrlByCulture(Item item, string culture)
{
string itemUrl = string.Empty;
if (item != null)
{
using (new Sitecore.Globalization.LanguageSwitcher(culture))
{
itemUrl = LinkManager.GetItemUrl(item, new UrlOptions() { LanguageEmbedding = LanguageEmbedding.Always });
}
}
return itemUrl;
}
Just one more explanation, basically in same solution/scenario when i am rendering through
<li runat="server" id="navAncharLi">
<a runat="server" id="navAnchar">
<sc:Text ID="TextTitle" Field="Title" runat="server" Item="<%# Item %>" DisableWebEditing="true" />
<strong runat="server" id="TagSubTitle">
<sc:Text ID="TextSubTitle" Field="SubTitle" runat="server" Item="<%# Item %>" DisableWebEditing="true" />
</strong> </a>
<em runat="server" id="navAncharHead"></em>
</li>
but when i am using a function to render from code behind then it's not creating issue & working perfect like shown in below code:
<li runat="server" id="navAncharLi">
<a runat="server" id="navAnchar">
<%# GetFieldValue(Item,"Title") %>
<strong runat="server" id="TagSubTitle">
<%# GetFieldValue(Item,"SubTitle") %>
</strong>
</a>
<em runat="server" id="navAncharHead"></em>
</li>
public string GetFieldValue(Item itemObj, string fieldName)
{
return itemObj.Fields[fieldName].Value;
}
But it's not seems to be good solution :)