Hello Devs,
There might be a situation, or you may have come across one,
“How to re-use a same content item across multi-site in a Sitecore
instance? “
Consider a scenario, lets say we have blog items which are global (i.e.
used on Site X and Site Y)
Obviously, the presentation details would be different (Site
X header, Site X footer, Site Y header, Site Y footer etc.)
You would be having a Blog landing page one for Site X and
Site Y which would list down all the blog items with read more link which
navigates to Blog detail page.
So, the ideal way would be that, if the user is on Site X
and clicks the read more link from landing page it should show presentation
details which are specific to Site X and vice-versa for Site Y.
As we are using the same content items across two sites, How would you handle Presentation details across Multi-Site?
Solution 1
One way would be that you create 2 Blog Detail page items one each for Site X and Site Y with Presentation detail of Site X and Site Y assign to them.
When the user is on Site X and clicks the Read more link it
would show the Blog Detail page with the Presentation details of Site X and
vice-versa for Site Y.
But it would require custom development. Right?
Solution 2
How about this, Sitecore OOTB provides device feature with
predefined set of Rules where we can define our own custom rules click here...
Create a new Layout device for Site Y (device name = Y device)
(Site X would use the default device) under : /sitecore/layout/Devices
Click Edit rule link and add the rule as shown in below
image :
The rule specifies that when the current Site is Y it should use Y device to render the Presentation details.
Now navigate to the Standard values of the Item template (in our case Blog Items) and set the Site-specific Presentation details. Use Default device for
Site X and Y device for Site Y.
Now when the user is on Site Y and opens the Blog Detail
page via Read more link it would display Site Y specific presentation details
and vice-versa for Site X.
In this way, we can re-use the same content items across
multi-site Sitecore Instance.
That’s it for now!!!