Teeknow
Teeknow

Reputation: 1015

Sitecore Link Manager Url Options Site Resolving is not Set

In a multisite solution I am using the following solution to allow switching between different link managers based on a site: http://thegrumpycoder.com/post/78684655662/sitecore-pipeline-enabled-linkprovider

This seems to be working as expected. The issue I'm running into is that siteResolving is not being set to true for the following configuration:

<linkManager defaultProvider="overridesitecore">
  <providers>
    <clear />
     ...
     <add name="someSiteSpecificLinkManager" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="false" alwaysIncludeServerUrl="true" encodeNames="true" languageEmbedding="always" languageLocation="filePath" lowercaseUrls="true" shortenUrls="true" useDisplayName="false" siteResolving="true"  />
     ...
  </providers>
</linkManager>

I've switched a few of the other settings just to make sure that they would change the link manager's default url options and they did. Is siteResolving not the correct attribute to use?

Upvotes: 3

Views: 5253

Answers (1)

Derek Hunziker
Derek Hunziker

Reputation: 13141

There is a long-standing issue with siteResolving not being applied to the link manager, regardless of it being configured correctly.

The solution is to apply the setting within your provider:

public class SiteResolvingLinkProvider : LinkProvider
{
    public override UrlOptions GetDefaultUrlOptions()
    {
        UrlOptions urlOptions = base.GetDefaultUrlOptions();
        urlOptions.SiteResolving = Settings.Rendering.SiteResolving;
        return urlOptions;
    }
}

See also: http://reasoncodeexample.com/2012/08/09/sitecore-cross-site-links/

It sounds like you have multiple providers, and you are trying to control the setting independently on each provider, correct? In that case, you can try supplying the siteResolving attribute on the link provider configuration (as you showed), then read in that configuration into a property on the LinkProvider:

public bool SiteResolving { get; set; }

public override void Initialize(string name, NameValueCollection config)
{
    base.Initialize(name, config);
    SiteResolving = MainUtil.GetBool(config["siteResolving"], true);
}

Upvotes: 8

Related Questions