Containers in dotCMS allow you to specify both what types of Content can be added to a Page and how content of each of those Content Types is displayed. Specifically, Containers allow you to perform the following important functions:
- Determine which Content Types a user can add to a Page.
- A user can not add content of a given Content Type to a Page unless the Page's Template includes a Container that accepts content of that type.
- Create blocks of code which are re-usable on multiple Templates.
- Containers (and especially Zero Content Containers) can contain code, which can then be shared among Templates and Pages by including the Container in multiple different Templates.
- Specify different and re-usable formatting and styling for each different Content Type that can be displayed in the Container.
- Individual content items are placed inside Containers, Containers are placed inside Templates, and Templates are placed inside Pages. So individual content items are ultimately displayed (and formatted) in Pages via Containers.
- You can also create different Containers that format and display the same Content Type in different ways (such as a summary view and a detailed view), allowing you to select how a Content Type is displayed in different Templates just by choosing the appropriate Container.
- Content Type Formatting
- Container Types
Content Type Formatting
Properly created containers control how the fields of each Content Type display on the Page (including whether or not each field of the Content Type is displayed at all). This ensures that content contributors don't have to worry about coding or CSS styling, and that all content of the same Content Type is displayed in the same way (even on multiple different pages). Content contributors simply contribute content by filling out each field available on the Content Type, and when the content is added to a Page it displays with the appropriate styling and selected fields for that Content Type.
Note: A given Container can only appear once in each Template, but each Container can be used on multiple different Templates (once in each Template).
There are two basic types of containers in dotCMS:
- Zero Content Containers do not have Content Types assigned to them.
- Content Containers allow content creators to add Content of certain Content Types to them.
Zero Content Containers (Headers, Footers, Side Navigation, etc.)
Zero Content Containers do not have Content Types assigned to them. The Max Contents property of the Container must be set to 0, and content contributors will not be able to add content to them.
Content Containers allow content creators to add individual content items to them. Content 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.
If the Max. Contents property is set to any number higher than zero, then the following Container properties can be set on a Content Container: