1

I have a Link field in Sitecore where user could choose any link, site has multiple languages and cultures. In case if user sets a page in the link field that does not have language in current context, I need to display neutral (default English language) link. How to do it if I have rendering like

 @using (Html.Glass().BeginRenderLink(link, x => x.MyUrl, listOfProps, isEditable: true))
 {
     @Html.Glass().Editable(link, m => m.Label)
 }
0

Sitecore datatypes links, multilist, tree list, drop links etc. should be set as Shared fields in Sitecore templates as they dont need any language specific versions for themselves (if you look at their RAW values, they are GUIDs or list of GUIDs). Instead the item these fields point to have language specific versions.


If there is requirement not to make these fields shared across the languages, try to add field level fallback for these fields and set fallback language to English.

2
  • it not about fallback, it is about url generator... Feb 12 '20 at 9:59
  • Ghanendra's note about field-level fallback is what you want in your case. With that enabled, it'll either present the link selected in that language, or it'll provide the fallback language however you have it configured in system/Languages. Feb 12 '20 at 14:28
0

You can set language embedding url options on the SitecoreField attribute of your model, for example:

 [SitecoreField(UrlOptions = SitecoreInfoUrlOptions.LanguageEmbeddingAlways|SitecoreInfoUrlOptions.AlwaysIncludeServerUrl)]
 public virtual Link Link { get; set; }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.