Adding a Container documentation for the dotCMS Content Management System

To add a new Container, select Containers from the Site Browser tab. From the Containers window press the Add Container button at the top right of the page.

Container Types

There are two basic types of containers:

  • Standard Containers (a.k.a. Content Containers) allow you to add content to the container within a Page (via the Page editor).
    • A container will be treated as a Standard Container when the Max. Content field is set to any value greater than 0.
    • Content Display Fields will only be displayed for Standard Containers.
    • Standard Container properties define all of the following:
      • Which Content Types can be contributed to the Container.
        • You may add one or more Content Types to the Container, and individual content items of all the added Content Types can be added to the Container.
      • How content of each allowable Content Type should be formatted when added to the page (e.g. which fields of the Content Type should be shown and how they should be displayed).
      • How many pieces of content can be contributed to the Container on a single Page.
        • The total number of individual content items of all allowable Content Types that can be added to the container.
      • Whether the content can edited through the inline editing mode.
      • Which users have Permission to contribute content to the Container.
  • Zero Content Containers do not allow content to be added to them.
    • These Containers function similar to a server-side include file and can be used to place reusable HTML elements, Javascript and Velocity code in multiple Templates and Pages.
    • These containers are typically used to display portions of the page which are shared among multiple Templates, such as global headers and footers, main navigation, and other code blocks used site-wide (which do not need to change on different pages).
    • A container will be treated as a Zero Content Container when the Max. Content field is equal to 0.

By default, new Containers have a Max. Contents of zero, so by default all new Containers will behave as Zero Content Containers. If you wish to allow content contribution in the new Container (and thus see the Content Display fields), change the Max. Content field to a number greater than zero.

Container Fields

The fields displayed in the Container editing screen change depending on whether you're viewing a Standard Container or a Zero Content Container, and whether you're creating a new Container or editing an existing Container.

New Containers

The following fields will be available when adding any new Container (regardless of whether it's a Standard or Zero Content Container):

FieldDescription
TitleTitle given to the Container by the user. This will be displayed when listing containers in both the Containers screen and when adding a Container to a Template.
DescriptionA short description of the Container. This is displayed only when viewing the Container editing screen.
Max. ContentThe maximum number of pieces of Content that a user can place in a Container. If set to 0, the Container will display only the fields available to Zero Content Containers; otherwise fields for a standard Container will be displayed, allowing you to add Content Types and code.
NotesYou may put any text in here you wish; content contributors may view this text when they add content to the Container in the Page Editor.

Saved Containers

After a Container has been saved at least once, the following additional fields will be displayed for all Containers (both Standard and Zero Content), though the values of these fields can not be changed:

FieldDescription
IdentityA unique key automatically assigned by dotCMS to identify the Container. This key is used when the Container is added to a Template, such as when a Container is added to an Advanced Template.
HostThe Site to which this Container is assigned. Although each Template and Container is assigned to a specific Site, they may still be used on any other Site on the same dotCMS instance.

Zero Content Containers

The following additional field will be available when creating or editing a Zero Content Container:

FieldDescription
CodeThe code placed in this field will be processed (once) when the Container is processed by the page.

Standard Containers

The following fields will be available when creating or editing a Standard Container:

FieldDescription
Pre-LoopYou may place HTML code here which will be parsed before any of the content in the Container is parsed. This field will only be processed once no matter how many content items are displayed by the container.
For example, you may add an opening HTML tag that will stipulate how the content will be formatted within the Container (such as <div class="class-name">).
Content Type/CodeSelects a Content Type which will be allowed in this Container, and allows you to enter different code for each selected Content Type, determining how content of that Content Type is displayed by this Container. After selecting the Content Type, press the Add Content Type button to add it to the Container.
Content Type TabFor each Content Type added (using the “Add Content Type” button) a tab will be added to the code portion of the Container. The code entered in each tab will be processed for each piece of content of the appropriate Content Type added to the Container. In each tab, you may add field values from the appropriate content by selecting the *Add Variable button and selecting the appropriate field name.
Post-LoopSimilar to the Pre-Loop, above, you may place HTML code here. The code in the *Post-Loop will be parsed before after all of the content in the Container is parsed. This field will only be processed once no matter how many content items are displayed by the container.
For example, you may add a closing HTML tag that will stipulate how the content will be formatted within the Container (such as </div>).