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.
- When using Velocity code in a container, the simplest way to access the content object is through the built-in
- 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 Added to Containers
- Each content item can only be added to each Container on a Page one time.
- If you attempt to add a content item to a Container that already contains it, the content item will not be added a second time.
- When content is added to a Container on a Page, that content will continue to appear on the Page even if the Template or Layout is changed, so long as the new Template or Layout includes the same Container the content was added to.
- The same Container may be used multiple times on the same Template or Page Layout.
- When the same Container appears multiple times on the same page, content added to one of the Containers is added to that specific Container (as identified by a unique number such as 1, 2, 3), and will only appear in the Page after a Template or Layout change if the same Container (including the numeric identifier) still appears on the Page after the Template or Layout change.