Sitecore Box

Sitecore web developer at Americaneagle.com

SITECORE Multi-Sites with Shared Pages



Overview

SITECORE support having multiple website in a single instance, every site has it is own pages, content, etc...  And you can add shared content items between all sites as you can see in the below screenshot:



That’s awesome! But the challenge comes when you need to have shared pages between more than one sites. Don’t worry it is doable, but we need to do some coding here.



What to do?

I am supposing that you know how to configure multiple website in the normal scenario, if you don’t, please check out this document by Sitecore.

After configuring our sites we need to go through the below steps to have the shared pages working fine:

1)   We need to override “GetItemUrl” method to update the URLs for the items under shared content to be formed the same as the links under the site itself.

We need to be able to browse the pages under the shared folder without include “/Global/” in the URL, for example if we are on “site1” (suppose that the URL is http://site1) and we want to browse this page “/sitecore/content/Global/Products/Product1” then the URL should be this http://site1/Products/Product1 instead of http://site1/Global/Products/Product1 and if we are on “Site2” the URL should be this http://site2/Products/Product1





2)   After updating the URL, now we need to process the request and update Context.Item” value since we don’t have “Products” item under the sites, and this can be done by adding a new processor to resolve such kind of request.

To do that we need to add a new processor in the <httpRequestBegin> to be inherited from HttpRequestProcessor class. In this processor we need to update this property “Context.Item” with the matched item based on the current request.


So in our above example the request will be:

Request: http://site1/Products/Product1

Context item : Sitecore.Context.Database.GetItem( “/sitecore/content/Global/Products/Product1”)



       Don’t forget to add the link provider and the processer to the config using the below              patch:


3)   The last step is make sure that your sitemap.xml is working as expected any update any code login accordingly.


0 comments:

Post a Comment