问题
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 :)
回答1:
Syed,
Looks like language fallback is happening in your case, as English is default language set in Sitecore. My ans would be whenever you are using getItem function pass the current context lang with it, also go with null point check.
For Example:
.GetItem(home.ID, language)
Hope this will work!!
Cheers!!
Nishant
回答2:
Thanks to everyone, finally after analyzing Sitecore support have come to an conclusion that it's because of WFFM bug which is resolved in new release.
reply of Sitecore support is below
I have investigated files and it seems the can be caused by the following bug in the WFFM module: https://sdn.sitecore.net/SDN5/Products/Web%20Forms%20for%20Marketers/Web%20Forms%20for%20Marketers%202,-d-,4/Release%20Notes/Release%20History.aspx An issue with incorrectly copied values in Title field while working with different content languages has been fixed (426013) The issue was fixed in the Web Forms for Marketers 2.4 rev. 150619 module version. Try to comment out the following processor in the Sitecore.Forms.Mvc.config:
<renderField>
<processor type="Sitecore.Forms.Mvc.Pipelines.Fields.AddFallbackValue,
Sitecore.Forms.Mvc"
patch:before="*[@type='Sitecore.Pipelines.RenderField.AddBeforeAndAfterValues,
Sitecore.Kernel']" />
</renderField>
Please let me know whether this helps
above solution worked for me & sitecore support also confirmed that.
You can comment this processor without any side effects for your solution. Alternatively, you can upgrade your WFFM module to the Web Forms for Marketers 2.4 rev. 150619 version: https://sdn.sitecore.net/Products/Web%20Forms%20for%20Marketers/Web%20Forms%20for%20Marketers%202,-d-,4/Module_Upgrades.aspx
来源:https://stackoverflow.com/questions/30913668/sitecore-empty-field-in-multi-culture