I'm looking to run two sites off one Sitecore install.
The first site will only be in UK English therefore I won't include the language in the file path. languageEmbedding=never
The second site will be in multiple languages and I need to include the language in the file path. languageEmbedding=always
Is there a way I can define multiple link managers and configure the sites to use a specific link manager?
I've found the best way was to create a custom link manager that supports both scenarios. Then have a supporting config setting which defines whether the language is embedded.
public class LanguageLinkProvider : LinkProvider
{
public override string GetItemUrl(Item item, UrlOptions urlOptions)
{
urlOptions.SiteResolving = Configuration.Settings.Rendering.SiteResolving;
string sites = ConfigurationManager.AppSettings["EmbedLanguageInUrl"];
var splitSites = new List<string>();
if (!string.IsNullOrEmpty(sites))
splitSites = sites.Split(';').ToList();
if (splitSites.Contains(urlOptions.Site.Name))
urlOptions.LanguageEmbedding = LanguageEmbedding.Always;
else
urlOptions.LanguageEmbedding = LanguageEmbedding.Never;
return base.GetItemUrl(item, urlOptions);
}
}
Nope, not by default.
But the LinkManager is overrideable. Probably you can change the behavior by selecting a different config per site and coding this into an overriden LinkManager.