Tag: Sitecore Patching

Inheriting Sitecore Site Properties with Sitecore Patching and Transformation

Challenge:

Sitecore is such a huge platform that every day you find something new and interesting. Happens with you as well? It is happening with me since last 7+ years! But I am enjoying learning it and then sharing it with you.

So, let’s say you have one site node defined with all basic things e.g. enablePreview, enableWebEdit, hostName, startItem, database etc. Now you would like to have one more site where you would like to use base attributes as earlier defined and you would like to modify few attributes only:

<sites>
<site name="site1" virtualFolder="/sitecore/admin" physicalFolder="/sitecore/admin" enableAnalytics="false" domain="sitecore" loginPage="/sitecore/admin/login.aspx"/>

<site name="site2" inherits="site1" />
<site name="site3" inherits="site1" domain="extranet" />
<site name="site4" inherits="site1" enableAnalytics="true" />
</sites>

I tried the same approach for my project and it works well. But only locally. When I deployed it on QA server it stopped working. After deep research I have found the source of the issue. I would like to share with you as well. Let’s go!

Solution:

As you would have done, I also did showconfig.aspx on server and then noticed that my site2 was getting added before site1 and that was causing this issue and it was happening because I was using SlowCheetah Transformation and inserting site2 based on environment. To fix it — I used patch:after=”site[@name=’site1′]” which fixed this issue. Here is how it looks new with transformation:

<sites>
<site name="site2" inherits="site1" patch:after="site[@name='site1']" xdt:Transform="Insert" hostName="site2.com" domain="extranet" enableAnalytics="true"/>
<site name="site3" inherits="site1" domain="extranet" />
</sites>

Enjoy!

Advertisements