OpenCms Documentation

Add Content Restrictions

 Show GitHub edit links  Hide GitHub edit links
In OpenCms since: 13.0 Documented since: 13.0 Latest revision for: 13.0 Valid for OpenCms: 13.0

Modular templates like the standard OpenCms template Mercury do not only provide reusable content element definitions but also sets of pre-prepared contents that can be used by editors to create pages. A typical example for pre-prepared contents are reusable responsive layout areas and layout rows.

With the Add content restrictions technique, the set of pre-prepared contents visible to editors when creating new content can be reduced.

Motivation

The original motivation behind the Add content restriction technique is to reduce the number of available page layouts in the Mercury template.

The figure below shows the Add content dialog of OpenCms' page editor. In this special situation, the editor did navigate to the Template elements view in the dialog, and the editor is just about to add one new Mercury layout row to a page.

As one can see, Mercury offers a large variety of responsive layout rows to the user. There are sites where this variety makes sense. For other sites a limited number is better—for example, if the site is intended for mobile devices mainly.

Fig. [add-content-dialog-layout-rows-full]: Add content dialog with all available Mercury layout rows

How to restrict contents

In order to restrict the contents provided in the Add content dialog for a site, proceed as follows:

  • open your Sitemap master configuration in the editor and go to the Restrictions tab
  • add a new Restriction to the list by at first selecting a content type
  • select a content by entering the VFS path of the content that should appear in the Add content dialog for this content type
  • optionally: enter a new name for the selected content
As soon as one restriction is added to the list, all contents of a specific content type that would normally appear in the Add content dialog are disabled. Only the manually selected contents from the restriction list are still available.

The figure below shows a Mercury Sitemap master configuration where the list of available layout rows is restricted to Row 1 column (12 - full). Since no other layout row is available any more, the title of the row is changed to Full row.

Fig. [master-configuration-tab-restriction]: Restriction tab of the Sitemap master configuration

If configured in this way, the only content appearing in the Add content dialog is the Full row layout content as configured above.

Fig. [add-content-dialog-layout-rows-restricted]: Add content dialog with restricted layout rows

Summary

This chapter describes how to restrict the list of pre-prepared contents that appear in the Add content dialog.

Although the original motivation is to restrict Mercury's large variety of layout rows, the technique works in other situations and for arbitrary templates and content types.