Ever wonder how to implement a pre-production preview website on Sitecore? Here are a few hints to get that done!

It is a common request from content authors in Sitecore that from time to time they needed to send internal URL to non-Sitecore users. Since these users generally do not have access to Sitecore how can they review the content before it goes live, for example?
As described here, on Sitecore 7.2 it was added the ability to implement pre-production publishing. Take a look at the link provided with a few useful hints to setup the pre-production publishing. Here are others that need to be done in order to get that working properly.

1- You need to have a site definition in place. To do that you can use the SiteDefinition.config file, located under App_Config/Include to add your site definition. Here is one example:

<site name=”preprod” patch:before=”site[@name=’website’]” virtualFolder=”/” physicalFolder=”/” rootPath=”/sitecore/content” content=”preprod” startItem=”/home” database=”preprod” domain=”sitecore” allowDebug=”true” cacheHtml=”false” htmlCacheSize=”0″ registryCacheSize=”0″ viewStateCacheSize=”0″ xslCacheSize=”0″ filteredItemsCacheSize=”0″ enablePreview=”true” enableWebEdit=”true” enableDebugger=”true” disableClientData=”false” hostName=”preview.mywebsite.com”/>

Note the hostName property. This is the url that the content authors will provide to non-sitecore users. Also the property database points to a new database “preprod”

2- On IIS, add the preview.mywebsite.com to the binding of your website. When you do that you will enable it to be resolved by your website.

3- Attach a new master database or create a snapshot of the existing one and re-attach to SqlServer. The connection string for this new database should be set to preprod:

<add name=”preprod” connectionString=”user id=myuser;password=mypassword;Data Source=MyDataSource;Database=sitecore_master_preview” />

4- On Sitecore create a new publication target. To do that, open the content editor and navigate to the path /sitecore/system/Publishing targets and create a new target which I`m naming preprod. After you do that check the checkbox “Preview publishing target”

5- Update your workflow definition to have the __OnSave action to publish it to the preprod database. This is required to help content authors when creating the content and having the content landing on the preview site:

Note that the target parameter has the same name as the publishing target created.

 

6- If you are dealing with an scaled environment you need to make sure that the publishing is properly configured. Please review Sitecore’s scaling guide for more details about this but items 7 and 8 will help you with that.

7- Make sure you preprod site is getting it’s cache cleared when the publishing is happening. To do that need to add it’s definition to the publish:end and publish:end:remote configurations to a HtmlCacheClear file definition.

Here is an example of how it could be defined:

 <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
 <sitecore>
       <events>
            <event name="publish:end">
                  <!--<handler type="Sitecore.Modules.RSS.PublishingHandler, Sitecore.Modules.RSS" method="OnPublishEnd"/>-->
                 <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
                       <sites hint="list">
                           <patch:delete />
                       </sites>
                       <sites hint="list">
                            <site>website</site>
                            <site>preprod</site>
                       </sites>
                </handler>
            </event>
            <event name="publish:end:remote">
                   <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
                          <sites hint="list">
                               <patch:delete />
                          </sites>
                          <sites hint="list">
                                <site>website</site>
                                <site>preprod</site>
                          </sites>
                   </handler>
            </event>
        </events>
</sitecore>
</configuration>

8- Now you need to properly configure the ScalabilitySettings.config file. It is by default disabled so the first thing you need to do is enabled it. When you do that you need to configure the Instance properties. This is really important to enable Sitecore to clear the cache properly after the content is published from the content management server into the content delivery nodes. Let’s assume you have one content management box with 2 content delivery nodes, here is an example on how the content management instance configuration should look like:

InstanceName = CA

Publishing.PublishingInstance = CA

Now you need to make this right for the content delivery nodes. They should have the Publishing.PublishingInstance properties with the exact same value as defined on the content management instance. In this case the value would be CA. So for the content delivery 1 you would have the values like this:

InstanceName = CD1

Publishing.PublishingInstance = CA

And the same goes for the content delivery 2 which in this case would look like this:

InstanceName = CD2

Publishing.PublishingInstance = CA

Don’t forget that the InstanceName property defined on the content management server(value CA) can assume any value but they should be consistent across CA, CD1 and CD2.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s