We have multiple sites in sitecore but all are edited by the same editors and they want to be able to edit it all in one place. The majority of our editors use EE.

Problems: When you follow a link (on a page on EE) or search and follow (in EE) to an item belonging to another site (than the one you are editing) it leads you to the full site address. In our case the public address of the site. We want it to lead directly to the editing of that page.

I know you can set up a "mirror" of the site on the cm server but then you need a new domain name for the new site on the cm server too as well as configuring the sites (We are currently adding a dynamic site provider using the items in the content tree) and also the cookie handling gets a bit weird. In short: I think this is a bad way of doing it for us.

Main idea:

Why not just use only id-parameter style links (sc_itemid=...) when working on the cm server?

Try 1: Configure the standard link provider in Sitecore to only use ?sc_itemid=GUID - linking style.

I failed to do that. Maybe it is possible, but I don't know how

Try 2: Use a very simple custom link provider on CM.


    <add name="sitecore">
      <!-- Use an extremely simple link-provider on cm-servers, only sending id and language as parameters -->
      <patch:attribute name="type">Foundation.Url.UrlHandlers.IDLinkProvider, Foundation.Url</patch:attribute>


using Sitecore.Data.Items;
using Sitecore.Links;
namespace Foundation.Url.UrlHandlers
    class IDLinkProvider : [NORMAL LINK PROVIDER HERE]
        static string host = null; // static as it may be kept between threads and requests. No worry if set twice or so.

        public override string GetItemUrl(Item item, UrlOptions options)
            // Use "parent" link provider if not content
            if ((item.Database.Name != "master" && item.Database.Name != "web") || !item.Paths.IsDescendantOf(item.Database.GetItem(Sitecore.Constants.ContentPath))) return base.GetItemUrl(item, options);

            string lang = item.Language.Name;
            if (options?.Language != null) lang = options.Language.Name; // If lang provided in options, use it.
            string url = "/" + lang + "?sc_itemid=" + item.ID + "&sc_lang=" + lang; 
            // Note the leading / to make it a full address. Required on for example the search in EE.
            // Also note the language in the file path too, to make language selector in EE work
            if (Sitecore.Context.Site != null && Sitecore.Context.PageMode.IsExperienceEditor) url += "&sc_mode=edit";
            if (options.AlwaysIncludeServerUrl) {
                // Note: Just use the local computers full dns name, this may work, or not work, for you.
                if (host == null) host = "https://" + System.Net.Dns.GetHostEntry("localhost").HostName;
                return host + url;
            return url;

I tried with an even simpler LinkProvider first but then I had to add some checks for it to work like only use it for stuff under the content-item (or it destroyed links in content editor etc) and also the sc_mode=edit was not added or remembered in the cookie correctly in some situations.


Is this a bad idea for some reason?

Have you got a better solution or improvements on this one?

PS I tried to post this on Sitecore's community forum but it was instantly marked as spam (?!)

Alternative idea instead of inheriting the standard link provider:

Maybe I could have added this linkProvider as yet another link provider, set my new as the default one and use a fallback mechanism where I load and call the "sitecore" link provider, instead of calling base.

Updates Some changes in the code after testing it in a real environment:

  • Only apply on master and web db and
  • Check that Site is set before trying to check if we are in ee-mode.
  • Handle cases where a host is required. I.e. when AlwaysIncludeServerUrl is true
  • There seems to be some probles with the langauage selector in experience editor when using this code despite the fact that I set <patch:attribute name="languageLocation">queryString</patch:attribute> it removes the language from the query string.... Oct 12, 2018 at 13:49
  • Solved the problem in sitecores language selector in EE by adding the language first in the address too. Updating code above. Oct 15, 2018 at 8:21


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.