Added by Arjé Cahn, last edited by Dennis Dam on Sep 27, 2007  (view change)

Labels:

types types Delete
templates templates Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

Defining a new template

In order to use a new document type you need to define it. Document types are defined in a file called 'types.xml'. The location of the file depends on how you build Hippo CMS.
In the earlier binary distributions of Hippo CMS (up to 6.02.xx) the types can be found in the webdav repository. (Location: http://localhost:60000/default/default.preview/types/). In later versions the types are in the directory structure of distribution, in hippo-cms-v6.xx.xx/cocoon/types.

An example of the types.xml file looks like:

<?xml version="1.0"?>
<types>
  <resources default="text">
    <resource name="text" label="Text page">
      <schema>repository://types/text/text.xsd</schema>
      <template>repository://types/text/text.xml</template>
      <css>repository://types/text/text.css</css>
      <layout>repository://types/text/layout.xml</layout>
      <bl>repository://types/text/business_logic.xml</bl>
      <i18n>repository://types/text/i18n</i18n>
    </resource>
    <resource name="collection" label="(CMS) Collection" type="abstract">
      <properties>repository://types/collection/properties.xml</properties>
    </resource>
  </resources>
</types>

Every resource refers to a document type. Abstract documents are not visible to the user, but are used for defining commonly used definitions. A resource consists of several source files, which make up the total definition of a document type:

Tag name Optional? version Description
template
no 6.02.00 Contains the initial contents of the document after creation.
schema no 6.02.00 An XML schema containing data definitions.
layout no 6.02.00 Contains presentation definitions, used to present the document.
bl no 6.02.00 Business Logic file. Contains business logic needed to display the document type properly.
css yes 6.02.00 A CSS style sheet used to style the generated form.
i18n yes 6.02.00 The location where the i18n messages are located.
postprocessing yes 6.02.00 If set, this XSL is used to convert the edited XML data before saving the document. note: the XML input for the postprocessing XSL is wrapped with a root element "result"
preprocessing yes 6.03.05 If set, this XSL is used to convert the XML document loaded from the repository. note: the XML input for the preprocessing XSL is exactly the XML in your repository document!
load yes 6.04.01 if set, this value is used as a source to load the pipeline. See the example below.
properties yes 6.02.00 Define properties which can be modified on the specific resource. The properties become editable from the 'documents' / 'assets' right panels. See this page for a detailed description.

A source file for one resource can be made up of several files. You can define this by providing a base and default attribute on the resource tag. The base is a folder containing the elements of a source file. The different parts are defined by key tags, which contents refer to the source file relative to the base folder. Using these keys, you can include separate files, e.g. in a layout file you could include the macros.xml file of the common resource, by adding this statement in your layout file:

<import href="common/macros"/>

The load directive

From HippoCMS version 6.04.01
You have the ability to specify a preprocessing XSL in types.xml to transform your content before it is loaded in the editor. The load feature takes this principle a little further and provides the opportunity to use your own source, from which the document is loaded. This can be any valid Source, which can be resolved by the CMS ( or: (Hippo-) Cocoon). Let's assume you're using a cocoon pipeline cocoon://.. for example. In this pipeline you're free to do any preprocessing, or fetch the document from any source you want, as long as the resulting XML is still valid according to the type's XML schema. You specify the "load" pipeline in types.xml, e.g.:

<resource name="text" label="types:cms.types.label.text" i18n:attr="label">
..
  <load>cocoon://extensions/load</load>
..
</resource>

the load pipeline will subsequently be called like this:

cocoon://extensions/load/text/content/foo/bar.xml

where text is the name of your backend template, and /content/foo/bar.xml is the path to the document.

More information about creating templates

Available XML Schemas