Kentico CMS 7.0 Developer's Guide

Previewing documents

Previewing documents

Previous topic Next topic Mail us feedback on this topic!  

Previewing documents

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

When you open the page in CMS Desk -> Content section, the default mode is Edit. This mode allows you to edit the page's content, design and properties.




The other view modes are:


Live site - this mode shows the page as it currently appears to visitors on the live site.

Preview - this mode also displays the current version of the page, but it may be used even for documents that are not actually published on the live site yet.

List - this mode shows a list of all documents under the currently selected document. This can be useful if there is a large number of documents under a single parent, or if you wish to perform an action for multiple documents simultaneously.


The following points summarize the difference between the Live site and Preview view modes:


The Live site and Preview modes display the same content when a document is published and no further changes have been made to it since it was published.

The Preview mode does not use caching, so it may display published changes that are not visible in Live site mode yet due to caching.

If a document does not use workflow and its Publish from property is set to a future date and time, the Live site mode does not display any content, while the Preview mode displays the content that will be published after the specified date and time.

If the document uses workflow and has not yet reached the Published step, the Live site mode doesn't display any content, while the Preview mode displays the content created in the current workflow step.

If the document uses workflow, is already in the Published workflow step and its workflow cycle has been restarted (i.e. it was switched from the Published/Archived workflow step back to the Edit step and is going through the workflow cycle again), the Live site mode displays the last published version, while the Preview mode displays content from the current workflow step.


Preview URLs


On the Properties -> General tab of an edited document, you can find the Preview URL property. If you click the Show preview link next to it, a new window will be opened, displaying the current document in Preview mode outside Kentico CMS user interface.




The document will be displayed on a special page with a dedicated URL. The URL can be sent to a person without access to Kentico CMS user interface to let them view content that is not published yet. At the top of the page, an info line is displayed, informing that the page is displaying a document preview in context of a specific user (the Show preview link is always leading to preview in context of the current user). Links on the page are intentionally not working, so the person who accesses the preview URL can only see the preview of the particular document.




Preview links are also included in workflow notification e-mail templates. In this case, the preview is displayed in context of the user who performed the workflow action about which the e-mail is notifying.




Generating new preview URLs


If you do not want the document's preview to be accessible under a link that you already sent to someone, you can generate a new preview URL for the document. This can be done by clicking on Generate preview (RebuildIndex) next to the Show preview link on the document's Properties -> General tab. By doing so, the document gets a new preview URL and the original one is no longer functional.




Depending on the Allow permanent preview links setting in Site Manager -> Settings -> Content -> Content management, new preview URLs can also be generated automatically for documents under workflow when their workflow cycle is restarted (i.e. when they are switched from the Published/Archived workflow step to the Edit step). If disabled, new preview URLs are generated in this situation and the original ones are no longer usable. If enabled, original preview links are preserved when the workflow cycle is restarted.


Additional configuration for long URLs in .NET 3.5


URLs in ASP.NET can have a maximal length of 260 characters. This may cause problems with links in previewed documents (e.g. links to attachments of documents which are nested deep in the content tree). If these URLs are long on their own, they may potentially exceed the length limit because the preview URL prefix is pre-pended to in document preview.


If you are running Kentico CMS on .NET 4.0, handling of such URLs is pre-configured in the default web.config file, so you should not encounter any problems. If you are running Kentico CMS on .NET 3.5, you need to perform the following steps in order to avoid problems with such URLs:


1. You need to install the URL Rewrite Module into the IIS. It can be downloaded from the following location:


2. Add the following rewriting rule into the <system.webServer> section of the project's web.config file:





     <rule name="Remove virtual context prefix" stopProcessing="false">

       <match url="^cmsctx/(.+)/-/(.+)$" />

       <action type="Rewrite" url="cmsctx/-/{R:2}" />