0

In Sitecore 8, we are currently generating menu items using Glass Mapper's @RenderLink method. We have set the "languageEmbedding" attribute of the LinkManager Provider to "never" but glass seems to ignore this setting.

$RenderLink(mi, x => x.Link_URL);

creates

http://domain.com/en/topics/xxxx

Looks like you can do this on a per item basis (http://blog.falafel.com/sitecore-removing-languages-from-urls/) by doing the following:

Sitecore.Links.LinkManager.GetItemUrl(item,
new Sitecore.Links.UrlOptions 
{ 
    AlwaysIncludeServerUrl = true, 
    LowercaseUrls = true, 
    LanguageEmbedding = Sitecore.Links.LanguageEmbedding.Never 
}); 

but I haven't been able to figure out how to get this into glass.

Does anyone know how to remove the "/en/" (language) from the link when using glass to render?

  • 1
    GlassMapper should respect the LinkManager options set in config, I've never had an issue with it so make sure your configs are as GoldenGrahamns point out. If you have added your own LinkProvider called something different than `sitecore` then make sure you have set the `defaultProvider` attribute correctly also. – jammykam Jun 04 '15 at 22:35

3 Answers3

3

You can set this on the SitecoreField attribute of your model

    [SitecoreField(UrlOptions = SitecoreInfoUrlOptions.LanguageEmbeddingNever|SitecoreInfoUrlOptions.AlwaysIncludeServerUrl)]
    public virtual Link Link { get; set; }
Michael Edwards
  • 6,308
  • 6
  • 44
  • 75
  • This put me on the right path. We are also using TDS so we ended up writing an extension method that contained the attributes mentioned. We also had to add one additional attribute that we found the generated.cs. `[SitecoreField(IMenu_ItemConstants.Link_URLFieldName, UrlOptions = SitecoreInfoUrlOptions.LanguageEmbeddingNever | SitecoreInfoUrlOptions.AlwaysIncludeServerUrl)]` – Nathan Abercrombie Jun 04 '15 at 18:35
  • As jammykam pointed out you shouldn't need to do this and the link provider should be respected. – Ian Graham Jun 05 '15 at 17:26
0

Double check something else is not overriding this setting. I would do a /sitecore/admin/showconfig.aspx just to make sure there isn't another linkprovider which has patched the web.config.

Ian Graham
  • 3,206
  • 1
  • 15
  • 23
0

Agree with the others. Check your showconfig. Failing that, do a search of all the config files. In my specific case, I found that Sitecore.Ecommerce.config was patching the linkmanager and wasn't showing in showConfig that it was doing so. After updating that config, the link manager functioned normally.

Note: Sitecore 8.0-u3, Active Commerce 3.2, SES 2.2

Craig Taylor
  • 1,173
  • 1
  • 7
  • 20