14

We have a multi-site setup and have the following sites defined in config:

<sites>
  <site name="mysite1" patch:before="*[@name='website']" rootPath="/sitecore/content/mysite1" startItem="home" hostName="mysite1.com" ... />
  <site name="mysite2" patch:after="*[@name='mysite1']" rootPath="/sitecore/content/mysite2" startItem="home" hostName="mysite2.com" ... />
</sites>

When content editors log in to the admin interface (mysite1.com/sitecore), they are able to see all the content in the tree for both sites, due to the way the roles and permissions are set up. Some users are in multiple roles and therefore can see content for multiple sites. The problem, however, is when a user tries to edit content using the Experience Editor—for mysite2, some elements of the site still refer to the logged-in site, e.g. mysite1.

Investigating further, it seems that Sitecore.Context.Site is set to "mysite1" in the Experience Editor.

What is the best way to allow the user to edit both sites separately in the Experience Editor?

2 Answers 2

16

In multi-site solutions, when you edit an item in the Experience Editor, Sitecore will by default resolve the site context using the value of the setting Preview.DefaultSite. It's located in Sitecore.config, and my guess is that you currently have it set to mysite1:

<setting name="Preview.DefaultSite" value="mysite1"></setting>

This means the default site context used by the Experience Editor will be mysite1.

You can change this behavior by setting another setting called Preview.ResolveSite to true. That will make Sitecore correctly resolve the site context of the item being edited:

<setting name="Preview.ResolveSite" value="true"></setting>

Note that on some Sitecore revisions you will need to apply the following hotfix in order for this feature to work correctly:

https://kb.sitecore.net/articles/382913

1
  • Does the Preview.ResolveSite setting only append the sc_site querystring parameter or does the url change to the corresponding site path as well?
    – bmyers
    Commented Oct 5, 2016 at 1:48
7

The sites are recognized using hostname and virtualPath. If your users login to EE using hostname from mysite1 and edit items they are using following url:

http://mysite1?sc_itemid={...}

so Sitecore, when attempting to recognize the site will match it to mysite1 because the hostname will match even if the actual item is from mysite2

2
  • How should the content editors edit content for mysite2 then?
    – jammykam
    Commented Oct 4, 2016 at 17:12
  • 1
    They can access EE using mysite2/sitecore. Then sitecore will match second site. Or you can mess with site resolving logic on requestBegin Commented Oct 4, 2016 at 17:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.