How to use one section of site from another site having same layout in sitecore?

Hey Experts – How’s your Sitecore journey going on? Today I would like to share power of device and fallback device in Sitecore with you. So let’s go ahead and first see the scenario where this can be helpful. Scenario/Requirement: Let’s say you have multi sites in your Sitecore instance. One of your sites have a section which needs to be pointed to another site by keeping same layout. Say for example – You have two sites, site-A and site-B. One of the section of site-B needs to be pointed to site-A. You can simply point to site-A section from site-B easily by giving respective item path of site-A. But challenge over here is – if you point to site-A from site-B then that section will show layout of site-A and you want to have layout of site-B. So how can you achieve this?

Solution: Below are steps involved to achieve this requirement: 1) Create a new Sitecore device for siteB by pointing fallback device to devices/default

 2) Add “device” attribute for siteB in SiteDefinition.config or web.config whichever you are using.  

3) Copy controls of section/item of site-A from default device to above newly created device using  presentation -> details option from Sitecore ribbon

Please remember that all the items/pages of siteB does not require to add controls in “siteB” device, you can add controls in “Default” device as well. You may have question then how will it work as we have mentioned that siteB should use device siteB in SiteDefinition.config file (as mentioned in step-2)? Yes – you are thinking correctly, but you need to also recall one more point – and that is “Fallback device” which is pointing to “Default” device (as mentioned in step-1). So flow is like this: Whenever any Sitecore page of siteB is requested –> It will first look for “siteB” device –> If “siteB” device is found then it will load controls inside that. Whenever any Sitecore page of siteB is requested –> It will first look for “siteB” device –> If “siteB” device is NOT found –> It will load fallback device controls (which is default device) Note: In this requirement, we don’t have any security constraint of pointing item from one site to another. Have A Happy Sitecore Journey!!!

Leave a Reply