Sitecore Experience Editor with different Site context

Challenge:

In Multi-Site Sitecore solution we allow user to load any site in Experience Editor with any Sitecore Site URL. We also provide an option to the user to create Sites on the fly. The problem we were facing was during Experience Editor. In Experience Editor you can make use of query string and get the Item based on sc_itemid. That was working absolutely fine. Now we provided an option to a user in Ribbon to change the color. Every Custom Site that user creates on the fly – each have their own fields to change the color.  We were not getting the correct site because Webutil was providing the below information.

Sitecore.Web.WebUtil.GetRawUrl(): “/-/speak/request/v1/expeditor/ExperienceEditor.GenerateFieldUrl”

Speak Request URL: http://sc8.com:80/-/speak/request/v1/expeditor/ExperienceEditor.GenerateFieldUrl

Now in this request you don’t get sc_itemid – we wanted to get the actual item id (sc_itemid) based on the current Site which user has loaded in Experience Editor, so that we can show/load the correct option to change the color.

Read More