Template models are container pages that you add to the sitemap via the sitemap editor. Clicking Create page, the available template models are shown in the tab "Container pages". When dragging a template model into the sitemap, the model is copied to create a new page. Typically, the template developer creates and configures model pages once he has finished the template JSP and content type implementation, but before editing the website’s contents.
The concept of template models allows to have some contents already placed on new pages and even to decide if a content should be copied to each new page or if the same content should be reused on each page.
We explain how to add new template models for your site and how to edit them.
Web pages usually have a common layout that should be altered only up to a certain level. Typically you may identify different kinds of pages that have lots of things in common. Template modelsTill OpenCms 9.0 known as model pages provide the "common parts" for pages of the same type. They contain all the contents that should be present on all pages of a kind and can also contain elements an editor has to fill with specific content when creating a new page using the template model.
Its worth to make a note on the relation between template JSPs and template models. In OpenCms the "frame" of each web page is provided by a template JSP. It is your design decision if you provide only the HTML head and a big container in the body of your template JSP, or if you already define a more specific structure of your web pages in the template JSP. Templates are changed by changing the template
property for a web page. You should keep in mind: what's placed in the template JSP is common to all pages using the template. If you change the template JSP, all pages using the template will change.
In contrast, a template model is just a container page with some content on it, that is used as master for new pages. Putting the layout into template models makes your design more flexible in the sense that you can provide a set of layout elements and a template developer who can edit template models. Thus new page layouts can be generated as in a modular construction system, without ever touching a JSP again. In contrast to the template JSP, changes of a template model not necessarily change already existing pages created from the model. If you drop a content from the template model, it will still be present on all pages created by the model. If you add a new content, it will not appear on existing pages created by the model and also property changes at the template model will not propagate to existing pages. Altering contents may influence the copies, if the content is reused on the generated pages and not copied.
Template models are created via the sitemap editor's "Templates" view. Open the sitemap editor, click "Select view" and choose "Templates". You get the following view.
To create a new template model you can click on the sign on "Template models" or open the context menu of an existing template model to copy it. Once the template model is created, click it's icon to edit it. You get a confirmation dialog before you can edit the page. It should guarantee you are aware of the implications of editing a model.
Editing a model is nearly exactly as editing any other container page. The only difference is a special element setting available for all elements on the pageExcept for element and inheritance groups.. If editing a template model, for each element you can decide if the element should be copied or reused if a page is created using the model. Therefor, click the gear wheel at the element to open the element settings. In the group "Template model options" the option "Copy this element" can be checked if the element should be copied. If the option is unchecked, the element will be reused.
When you add a new template model, the container page is created (in the current sitemap's subfolder .content/.templates/
) and configured as model in the sitemap configuration. In this configuration file (.content/.config
under the sitemap's main folder) you have further configuration options, found under the tab "Model pages". You can: