2.2.4.24. Template

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

This plugin is used to create templates into the system. A template is a presentation to display the saved information.

The node type template is used to edit and display the node content. Each node type has one dialog1.gtmpl file (dialog template) for editing/creating a node and one view1.gtmpl file (view template) for viewing the node content. Using the dialog template, you can specify a dialog whose fields correspond to the properties of the node you want to edit their values. When this template is rendered, each specified field will appear with a data input box for you to edit. Note that you do not have to design a dialog in which all data of the node are listed to be edited. You can just list the subset of node data you want to edit. Like the dialog template, the view template renders information of the node. You just need to create the template and specify which data fields to be displayed. With this kind of template, node information is only displayed but cannot be edited. See details at ContentType.

To use the plugin in the component configuration, you must use the following target-component:


<target-component>org.exoplatform.services.cms.templates.TemplateService</target-component>

The configuration is applied mainly in packaging/wcm/webapp/src/main/webapp/WEB-INF/conf/dms-extension/dms/dms-templates-configuration.xml.

Sample configuration:

This below example is configuration for the nt:file template, any other template will be put in the same level with this template starting from the line <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig$NodeType> as the another node type.


<external-component-plugins>
    <target-component>org.exoplatform.services.cms.templates.TemplateService</target-component>
    <component-plugin>
        <name>addTemplates</name>
        <set-method>addTemplates</set-method>
        <type>org.exoplatform.services.cms.templates.impl.TemplatePlugin</type>
        <init-params>
            <value-param>
                <name>autoCreateInNewRepository</name>
                <value>true</value>
            </value-param>
            <value-param>
                <name>storedLocation</name>
                <value>war:/conf/dms-extension/dms/artifacts/templates</value>
            </value-param>
            <value-param>
                <name>repository</name>
                <value>repository</value>
            </value-param>
            <object-param>
                <name>template.configuration</name>
                <description>configuration for the localtion of templates to inject in jcr</description>
                <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig">
                    <field name="nodeTypes">
                        <collection type="java.util.ArrayList">
                            <value>
                                <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig$NodeType">
                                    <field name="nodetypeName">
                                        <string>nt:file</string>
                                    </field>
                                    <field name="documentTemplate">
                                        <boolean>true</boolean>
                                    </field>
                                    <field name="label">
                                        <string>File</string>
                                    </field>
                                    <field name="referencedView">
                                        <collection type="java.util.ArrayList">
                                            <value>
                                                <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig$Template">
                                                    <field name="templateFile">
                                                        <string>/file/views/view1.gtmpl</string>
                                                    </field>
                                                    <field name="roles">
                                                        <string>*</string>
                                                    </field>
                                                </object>
                                            </value>
                                            <value>
                                                <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig$Template">
                                                    <field name="templateFile">
                                                        <string>/file/views/admin_view.gtmpl</string>
                                                    </field>
                                                    <field name="roles">
                                                        <string>*:/platform/administrators</string>
                                                    </field>
                                                </object>
                                            </value>
                                        </collection>
                                    </field>
                                    <field name="referencedDialog">
                                        <collection type="java.util.ArrayList">
                                            <value>
                                                <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig$Template">
                                                    <field name="templateFile">
                                                        <string>/file/dialogs/dialog1.gtmpl</string>
                                                    </field>
                                                    <field name="roles">
                                                        <string>*</string>
                                                    </field>
                                                </object>
                                            </value>
                                            <value>
                                                <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig$Template">
                                                    <field name="templateFile">
                                                        <string>/file/dialogs/admin_dialog.gtmpl</string>
                                                    </field>
                                                    <field name="roles">
                                                        <string>*:/platform/administrators</string>
                                                    </field>
                                                </object>
                                            </value>
                                        </collection>
                                    </field>
                                    <field name="referencedSkin">
                                        <collection type="java.util.ArrayList">
                                            <value>
                                                <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig$Template">
                                                    <field name="templateFile">
                                                        <string>/file/skins/Stylesheet-lt.css</string>
                                                    </field>
                                                    <field name="roles">
                                                        <string>*</string>
                                                    </field>
                                                </object>
                                            </value>
                                            <value>
                                                <object type="org.exoplatform.services.cms.templates.impl.TemplateConfig$Template">
                                                    <field name="templateFile">
                                                        <string>/file/skins/Stylesheet-rt.css</string>
                                                    </field>
                                                    <field name="roles">
                                                        <string>*</string>
                                                    </field>
                                                </object>
                                            </value>
                                        </collection>
                                    </field>
                                </object>
                            </value>
                        </collection>
                    </field>
                </object>
            </object-param>
        </init-params>
    </component-plugin>
</external-component-plugins>

In which:

Value-param Type Value Description
autoCreateInNewRepository boolean true Enables the application to import predefined templates at the start-up of template service automatically.
storedLocation string war:/conf/dms-extension/dms/artifacts/templates The location of stored templates.
repository string repository Location of stored templates.
Field Type Value Description
nodeTypes ArrayList {java.util.ArrayList}The node type of the template.
Field Type Value Description
nodetypeName string nt:fileThe name of template that is saved as a node in system.
documentTemplate boolean true Determines if the node type is a document type.
label string file Visual display of the title for this node.
referencedView ArrayList {java.util.ArrayList}Determines how to display a view.
referencedDialog ArrayList {java.util.ArrayList}Determines how to display a dialog to input information.
referencedSkin ArrayList {java.util.ArrayList}Determines the stylesheet for display.
Field Type Description
templateFile string The location of the file store for the template's presentation.
roles string Determines who can access this object (View/Dialog/CSS).
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus