0
votes

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?

3
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

3 Answers

3
votes

You can set this on the SitecoreField attribute of your model

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

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.

0
votes

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