Sitecore

Page Preview Master/Web Paradox

Does this scenario sound familiar?

  • Sitecore CM/CD are on different servers
  • Developer doesn’t have access to the CD server that is currently showing an error in the browser.
  • Code base for both CM and CD are the same.
  • Developer switches the database from Master to Web in CM and then previews the page but no error is shown on the page or in the logs.
  • Client has to wait until access can be given to the developer to investigate the issue

What if there was a better way?

How can I reproduce this issue?

I recommend that you download and install Sitecore Extensions but it is not required in order to reproduce the issue.

  • Click on this link and then scroll all the way to the bottom to download the zip file based on the browser where you want to install it.

Sitecore Ext Screenshot

Now that Sitecore Extensions is installed let’s make the following changes.

  • Find the Sitecore Extenisions button (see screenshot below) and click “Options

Sitecore Ext Screenshot 2

  • Go to Modules > Database color
Sitecore - Understanding Development Approaches: A Sitecore Outlook
Understanding Development Approaches: A Sitecore Outlook

Designing, building, and implementing top-notch experiences not only requires a great deal of planning, strategy, and time – it also requires the right digital experience platform (DXP) and the right development approach for your business needs.

Get the Guide

Sitecore Ext Screenshot 3

  • Click on the “Color Mapping” tab to start adding the Database names and colors.

Sitecore Ext Screenshot 4

  • Go to /sitecore/content/home
    • Under the master database
      • Change the Title field value to “Inside Master”
    • Under the web database
      • Change the Title field value to “Inside Web”
    • Screenshot below will show where you can go to change the database in Sitecore

Sitecore Ext Screenshot 6

  • Click Publish > Experience Editor under the Master database and you will see something like this below.

Sitecore Ext Screenshot 7

  • Switch to the web database, click Publish > Experience Editor under the Web database and you will see the exact same thing.   Now how do we fix this issue.

How do I make Preview show Web content instead of Master content?

There are 2 ways you can solve this issue

  1. Add the following url parameter when you are Preview mode (master or web)
      • &sc_database=web
      • It should now look like this below

    Sitecore Ext Screenshot 8

  2. Use the patch below to change the value of defaultContentDatabaseName from “master” to “web”
      • Always go with the first option and only use this option if the first one doesn’t seem to be working correctly.   Make sure to change it back immediately after you see the preview so you don’t potentially cause other issues.
      • defaultContentDatabaseName is a Sitecore global variable used by the shell site to determine what database to use to show the content.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore> 
    <sc.variable name="defaultContentDatabaseName" value="web"/>
  </sitecore>
</configuration>

 

 

 

 

 

About the Author

CJ became a certified Sitecore developer in 2015. In his spare time, he enjoys playing video games, basketball and racquetball.

More from this Author

Thoughts on “Page Preview Master/Web Paradox”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up
Categories