I previously blogged about a Switching Link Provider for Sitecore, allowing you use a different LinkProvider for different sites.
There were a number of changes in Sitecore 8.2 to LinkManager/Provider as a result of the Dependency Injection changes, unfortunately one of them being the
Providers collection being marked
[Obsolete]. The code in the old post should still work, but you’ll get that annoying warning.
The previous code worked by creating a Link Provider which acted as a switcher that in turn called a different Provider. This was a hack because we could not switch out the Link Manager itself. Well the DI changes in Sitecore 8.2 allow us to do that instead and provide our own implementation of LinkManager instead.
I’ve been using this Site Specific Link Provider for a while now and have been meaning to blog it for some time, a couple of recent blog posts from John West and the addition of the new LinkProviderSwitcher to Sitecore 8 about prompted me to finally get my thoughts onto keyboard. When I read that a new LinkProviderSwitcher had been provided I got a bit excited that we may finally have site specific link provider, alas it was just a way of allowing us to switch the provider inside a using block.
Some of you may be aware that Sitecore has allowed us to define multiple Link Providers for some time, we just add multiple
providers to the
linkManager config section, but it hasn’t really provided us a nice way of utilizing that functionality without hard-coding it: