View a document in the preview and live environment 

Viewing a document in the preview and live environment

Since CMS 7.6 and HST 2.21.01

The 'View' menu is available since CMS 7.6 and HST 2.21.01. Projects with older CMS and HST versions can use the Goto plugin to achieve similar functionality. Newer projects should not use the Goto plugin anymore.

Replaced in CMS 7.7

CMS 7.7 and higher include a new View menu that lists all channels a document is part of. The View plugin and its configuration described on this page are therefore no longer necessary in CMS 7.7, and can be removed when upgrading from 7.6 to 7.7.

The document editor contains a 'View' menu with the options 'Preview environment' for an unpublished document, and 'Live environment' for a published one. Documents with both a published and unpublished version will have a menu with both options. Clicking on a menu item shows the document in the preview or live environment.

 

http://www.onehippo.org/binaries/sixteencolumn/content/gallery/connect/library/view-menu.png

CMS configuration

The URLs for the document in the preview and live environment are generated by two 'document url services' in the CMS.
The generated URLs have the following syntax:

  <protocol>://<domain>:<port>/<path>?type=<type>&uuid=<uuid of document>

The document URL services can be configured in the console at:

 /hippo:configuration/hippo:frontend/cms/cms-services/previewSiteDocumentUrlService
 /hippo:configuration/hippo:frontend/cms/cms-services/liveSiteDocumentUrlService

Both configuration nodes are of the type 'frontend:pluginconfig' and should contain the following string properties:

  • domain
    The domain part of the URL.
    Default: localhost

  • path
    The path part of the URL.
    Default: /site/previewfromcms (which works out of the box on localhost)

    HST note

    The only path recognized by the HST is '/previewfromcms'. For example:
    http://www.example.com/previewfromcms?uuid=7d92c518-511b-49e0-92b5-126970694fa8&type=live.
    The HST will automatically redirect such a URL to the page for the document with that UUID.

  • plugin.class
    CMS plugin class that creates the document URLs.
    Default: org.hippoecm.frontend.service.documenturl.SiteDocumentUrlService

  • protocol
    The protocol part of the URL.
    Default: http

  • port
    The port part of the URL.
    Default: 80

  • service.id
    The ID of this document url service. Other CMS services can reuse this service by looking up the same ID.
    Default values:

    • 'preview.site.document.url.service' for the node previewSiteDocumentUrlService

    • 'live.site.document.url.service' for the node liveSiteDocumentUrlService

  • type
    Type of URL to generate.
    Possible values: 'preview' and 'live'
    Default values:

    • 'preview' for the node previewSiteDocumentUrlService

    • 'live' for the node liveSiteDocumentUrlService

The menu itself is rendered by the 'website actions' plugin. Its configuration is located at:

 /hippo:configuration/hippo:workflows/websiteactions/button/frontend:renderer

The website actions plugin recognizes the following properties:

  • live.document.url.service.id
    Service ID of the document URL service that provides URLs for the live environment.
    Default: live.site.document.url.service

  • plugin.class
    CMS plugin class that renders the menu.
    Default: org.hippoecm.frontend.plugins.websiteactions.WebsiteActionsPlugin

  • popup.service.id
    Service ID of the service that opens the popup window.
    Default: ajax.popup.service

  • preview.document.url.service.id
    Service ID of the document URL service that provides URLs for the preview environment.

Example custom configuration

Each custom project has to replace the default configuration of the document URL services to render the correct URLs for the project-specific preview and live environment(s).
The default configuration can easily be customized using the advanced XML import syntax.

Example for the site www.example.com :

Create the file 'document-url-services.xml' :

<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:h="http://www.onehippo.org/jcr/xmlimport" sv:name="cms-services" h:merge="combine">
  <sv:node sv:name="previewSiteDocumentUrlService" h:merge="combine">
    <sv:property sv:name="domain" sv:type="String" h:merge="override">
      <sv:value>www.example.com</sv:value>
    </sv:property>
    <sv:property sv:name="path" sv:type="String" h:merge="override">
      <sv:value>/previewfromcms</sv:value>
    </sv:property>
    <sv:property sv:name="port" sv:type="String" h:merge="override">
      <sv:value>80</sv:value>
    </sv:property>
    <sv:property sv:name="protocol" sv:type="String" h:merge="override">
      <sv:value>http</sv:value>
    </sv:property>
  </sv:node>
  <sv:node sv:name="liveSiteDocumentUrlService" h:merge="combine">
    <sv:property sv:name="domain" sv:type="String" h:merge="override">
      <sv:value>www.example.com</sv:value>
    </sv:property>
    <sv:property sv:name="path" sv:type="String" h:merge="override">
      <sv:value>/previewfromcms</sv:value>
    </sv:property>
    <sv:property sv:name="port" sv:type="String" h:merge="override">
      <sv:value>80</sv:value>
    </sv:property>
    <sv:property sv:name="protocol" sv:type="String" h:merge="override">
      <sv:value>http</sv:value>
    </sv:property>
  </sv:node>
</sv:node>

And add to your 'hippoecm-extension.xml':

<sv:node sv:name="exampledotcom-cms-services">
  <sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>hippo:initializeitem</sv:value>
  </sv:property>
  <sv:property sv:name="hippo:contentresource" sv:type="String">
    <sv:value>document-url-services.xml</sv:value>
  </sv:property>
  <sv:property sv:name="hippo:contentroot" sv:type="String">
    <sv:value>/hippo:configuration/hippo:frontend/cms</sv:value>
  </sv:property>
  <sv:property sv:name="hippo:sequence" sv:type="Double">
    <sv:value>20000</sv:value>
  </sv:property>
</sv:node>

Removing the 'View' menu

The view menu can be removed entirely with the following steps:

1. Remove the value 'websiteactions' from the multi-string property 'workflow.categories' in these nodes:

/hippo:configuration/hippo:frontend/cms/cms-preview/workflowPlugin
/hippo:configuration/hippo:frontend/cms/cms-compare/workflowPlugin

2. Remove the node

/hippo:configuration/hippo:workflows/websiteactions/button/frontend:renderer/websiteactions

Do not remove the document URL services nodes, as they are reused by other CMS services.