LibrarySites.Banner

Multiple Item Versions in Web Database

In Sitecore, it used to be that the master database would hold all versions of all items and the web database would hold just the latest publishable version of each item. In Sitecore 8.0 however, it's now possible to have multiple versions of an item in the web database.

In Sitecore, it used to be that the master database would hold all versions of all items and the web database would hold just the latest publishable version of each item. In Sitecore 8.0 however, it's now possible to have multiple versions of an item in the web database.

Sitecore 8.0 introduced Content Testing which allows users to test different versions of the same item to ensure the newer version doesn't have a negative overall impact on the site. To allow this functionality to work we require all those versions involved in the test to be present in the web database (actually, in all publishing targets). This allows the testing functionality to use the appropriate version, whether the old version or the new, depending on how the test strategy has chosen the experience to expose to the user.

The publishing of multiple versions is achieved through the introduction of a new pipeline in Sitecore 8.0, the publishVersion pipeline. This pipeline is executed for each item version that is published.

By default the publishVersion pipeline contains two processors in order:

  • Sitecore.ContentTesting.Pipelines.PublishVersion.PublishTestingVersions, Sitecore.ContentTesting
  • Sitecore.Publishing.Pipelines.PublishVersion.Processors.RemoveOtherVersions, Sitecore.Kernel

PublishTestingVersions Processor

The PublishTestingVersions processor is responsible for publishing all versions of an item involved in a content test to ensure the content test can run properly. Note that this processor will only copy additional item versions to the publishing target if the source item has a content test configured. If there is no test then this processor will have no affect.

This processor will abort the pipeline if it has processed a test, to ensure the next processor does not run, which would undo the work this processor has just done.

RemoveOtherVersions Processor

The RemoveOtherVersions processor implements the previous publishing behaviour and removes any versions of the item except for the latest version.

Extension

Although not a common scenario, developers can add their own processors to the pipeline to customise the behaviour of publishing an item version. Simply create a class with a Process method that accepts a single parameter of type Sitecore.Publishing.Pipelines.PublishVersion.PublishItemVersionArgs. Here's a skeleton of what a custom processor may look like:

public class CustomVersionProcessor
{
    public void Process(Sitecore.Publishing.Pipelines.PublishVersion.PublishItemVersionArgs args)
    {
        // Custom logic here
    }
}

Conclusion

Unlike previous versions of Sitecore where an item only ever had a single version in a publishing target, Sitecore 8.0 allows multiple versions of an item for those items involved in a content test.

Alistair Deneys
Content Testing Project Team