Inheriting Sitecore Site Properties with Sitecore Patching and Transformation


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:

<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" />

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!


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:

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


Getting Sitecore Dictionary in JavaScript

It’s very easy to get translations in back-end code — either Razor views or .cs files — by simply calling to


But what about JavaScript widgets? There we have several options:

  • Item Web API results in overhead and is hard to use without additional implementation.
  • StringDictionary embeds values right in HTML and needs to be configured accordingly.
  • Injecting translated text into .js components via HTML tags has the same drawbacks as StringDictionary.

All these options are cumbersome and inconvenient.

Continue reading “Getting Sitecore Dictionary in JavaScript”

Complete Unit Testing In Sitecore

Unit testing is Sitecore can be tricky. There are a lots of moving parts. And to truly be able to test, you need to somehow bring all of those parts into a test.

Unit testing could be divided into two different type: regular Unit Tests (just to test BusinessLogic without data relations) and Integration Unit Tests.

In the current article I will focus on Integration Unit Tests. In the futher articles I will describe how to write UnitTests without strong coherence with Sitecore.

So, to accomplish the main goal and have working UnitTests I will try to do the following:

  • Execute unit tests within a valid Sitecore context
  • Load all current App_Config/Include/ configs at runtime
  • Access to all APIs
  • Maintain to additional config files
  • No scripting involved

According to our goals let’s find a way of how to reach it. It’s mostly screenshots and code samples anyways.

Continue reading “Complete Unit Testing In Sitecore”

Sitecore Content and Page Editor: Injecting of resources

Image, that there is a need to add some external script inside Content Editor or/and PageEditor. What do you do? Might be you would start with developing of a custom field type that requires Google Maps API. Maybe many of your renderings use an external library or a client side helper of your own when in IsPageEditorEditing(). Whatever the case might be you may want to inject resources into your Content and Page Editor environments and do it once globally. And in a declarative way. This blog post will explain you the exact way of how to do it.

Continue reading “Sitecore Content and Page Editor: Injecting of resources”

Extending Computed Fields in Sitecore By Adding Parameters

Computed Fields In Sitecore

The purpose of computed fields is to create pre-calculated values when working with indexes. Such approach allows to proceed with the search though distributed data or even when some data is outside the Sitecore (data from the external services could be taken into the Sitecore search engine).

There are many interesting use-cases of how to use computed indexes. I’m going to share some tips to help people get the most of them.

Continue reading “Extending Computed Fields in Sitecore By Adding Parameters”

Sitecore: 404 without 302.

Sitecore: 404 without 302.

This post shows how to handle a request for a page which is not found, how to avoid having the request being redirected with a 302 status code before a 404.

How Sitecore handle NotFoundItem

Sitecore lets you specify a page to use for ‘ItemNotFound’ errors in web.config, and it’s always good practice to have a pretty ‘page not found’ page:

<setting name="ItemNotFoundUrl" value="/404" />

When Sitecore can’t find the requested item, it will redirect the user to the page that is configured in the setting ItemNotFoundUrl.

However, during the redirecting the response returns an HTTP status code 302 (Moved Temporarily). This is sad, as search engines don’t understand that the page actually hasn’t been found.

For search engine optimization, you should return the HTTP 404 status code for any invalid URL by setting the Status property of the current System.Web.HttpResponse

Continue reading “Sitecore: 404 without 302.”

User friendly development in Sitecore

User friendly development in Sitecore

Sitecore is an ideal product to manage complex websites. Editors which don’t have a technical vision but oriented in marketing only – it’s a little bit tricky to understand the custom made things.

Here I will show a few examples of how to implement things on a user friendly manner. That is also nice for the tester and other developers to find quickly the way in the created page templates and components.

It takes some time to make a beautiful and user-friendly Sitecore CMS environment. But at the end a user friendly Sitecore implementation save time and makes it fun to work with. Be nice to the editors, the user friendly cms implementation help to use thethings as they are intended.

Continue reading “User friendly development in Sitecore”