Thursday 27 February 2014

How to add a new publishing target in Sitecore

Leave a Comment
In this blog post, I am going to explain how to add a new publishing target in Sitecore.  Basically publishing target comprises of a target database (where the content will be published) and publishing target definition item in master database that points to that target database. We create target database entry in ConnectionStrings.config file and specify publishing target definition item in content tree at path /sitecore/system/Publishing targets.

Creating a new publishing target is very helpful if your Sitecore environment is setup in multiple content delivery servers. We can publish data from Master database to one or more publishing target databases. Main thing to notice here is Master database contains all versions of any content or assets while publishing target database contains single latest version for each language.

Below are the steps to add a new publishing target in Sitecore:
  • Create target database (where the content will be published) entry in ConnectionString.config 
    <add name="preprod" connectionString="user id=sa;password=sa;Data Source=.;Database=Sitecore_PreProdDatabase"/>
  • Open web.config and search for <databases> node.
  • Copy and paste any existing <database> node and change the database id with the connection string name.
      <!-- preprod-->
          <database id="preprod" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
            <param desc="name">$(id)</param>
            <connectionStringName>$(id)</connectionStringName>
            <icon>Software/16x16/application_server.png</icon>
            <dataProviders hint="list:AddDataProvider">
              <dataProvider ref="dataProviders/main" param1="$(id)">
                <prefetch hint="raw:AddPrefetch">
                  <sc.include file="/App_Config/Prefetch/Common.config"/>
                  <sc.include file="/App_Config/Prefetch/Core.config"/>
                </prefetch>
              </dataProvider>
            </dataProviders>
            <workflowProvider hint="defer" type="Sitecore.Workflows.Simple.WorkflowProvider, Sitecore.Kernel">
              <param desc="database">$(id)</param>
              <param desc="history store" ref="workflowHistoryStores/main" param1="$(id)"/>
            </workflowProvider>
            <archives hint="raw:AddArchive">
              <archive name="archive"/>
              <archive name="recyclebin"/>
            </archives>
            <cacheSizes hint="setting">
              <data>20MB</data>
              <items>10MB</items>
              <paths>500KB</paths>
              <itempaths>10MB</itempaths>
              <standardValues>500KB</standardValues>
            </cacheSizes>
            <Engines.HistoryEngine.Storage>
              <obj type="Sitecore.Data.$(database).$(database)HistoryStorage, Sitecore.Kernel">
                <param connectionStringName="$(id)">
                </param>
              </obj>
            </Engines.HistoryEngine.Storage>
            <NotificationProvider type="Sitecore.Data.DataProviders.$(database).$(database)NotificationProvider, Sitecore.Kernel">
              <param connectionStringName="$(id)">
              </param>
              <param desc="databaseName">$(id)</param>
            </NotificationProvider>
          </database>
    
  • Add publishing target definition item in master database.  Navigate to /sitecore/system/Publishing targets. Right click and add insert new publishing target.
  •  Give any significant name to publishing target definition item.  Enter database id in the Target database Field. 
  • Open Sitecore publishing dialog and you can see newly created publishing target.
Comments and suggestions are most welcome. Happy coding!   

0 comments :

Post a Comment