The Patchwork configuration

The heart of Patchwork is the patchwork configuration file patchwork.xml. The location of this file can be configured using the parameter patchwork-config for the Patchwork manager as shown in section Installation. If no such parameter is set, Patchwork searches for such a file in the same directory where the root sitemap resides.

Below you can find an example of a Patchwork configuration file that contains every element and attribute that are possible with this configuration. Not that complex, right?

<patchwork version="1.0">

  <!-- Callable layout definitions -->

  <layout name="index" extends="abstract.default" callable="true">
    <include name="main" template="templates/welcome.html"/>
  <layout>

  <layout name="news" extends="abstract.default" callable="true">
    <include name="main" layout="abstract.news"/>
  <layout>

  <layout name="webnews" extends="abstract.default" callable="true">
    <include name="main" layout="abstract.webnews"/>
  </layout>

  <!-- Abstract layout definitions -->

  <layout name="abstract.default" template="templates/index.html">
    <include name="header" template="templates/header.html"/>
    <include name="left" template="templates/left.html"/>
    <include name="main"/>
  <layout>

  <layout name="abstract.news" template="templates/news.html">
    <property name="title" value="News"/>
    <include name="newslist" template="templates/newslist.html"/>
  </layout>

  <layout name="abstract.webnews" extends="layout.news">
    <property name="title" value="Web News"/>
    <include name="newslist" template="templates/webnewslist.html"/>
  <layout>

</patchwork>

The root element of a Patchwork configuration file must be <patchwork version="1.0"/> where the attribute version defines the version of Patchwork used. Within the root element you can define as many layout/ elements as you want. In the example above you can see that the layouts index, news and webnews are callable="true". This means that they can be called from outside and therefore they are "public". Beside of that all of them are extending the layout abstract.default by using the attribute extends. The layout abstract.default defines the master template template/index.html and the three includes header, left and main. That is common for all callable layouts. Each callable layout overwrites the include main by placing a different layout there.

Elements and attributes reference

Below you can find the reference for all elements and attributes allowed within the standard Patchwork configuration:

XML elementDescriptionAllowed childrenAttributes
<patchwork>The only allowed root element for each patchwork configuration.<layout>, <content>version (string, required) : Defines the version of the Patchwork engine to be used.
<layout>Defines a new layout.<include>, <content>name (string, required) : Defines the unique name of this layout.
template (uri, optional) : Defines the path to the template file for the layout. All uri schemes that are supported by Cocoon can be used here. Especially if you want to include a result from a Cocoon pipeline you could use the pseudo protocol codecocoon://code to point to that pipeline and to use its serialized content as template. If no such attribute is given, at least one of the inherited layouts must have defined one. Otherwise an exception will be thrown.
extends (string, optional) : Defines the layout from there to inherit all of its definitions. Inherited values are: properties, includes and the value of the attribute codetemplate/code. All inherited values can be overwritten.
callable (boolean) : This tells the patchwork framework whether the layout is fully prepared for display and therefore can be called. Possible values are codetrue/code or codefalse/code. The default value is codefalse/code.
<include>Includes a template path or another layout into the current layout.Nonename (string, required) : Defines the variable name of the include. This variable name can be used within the template to refer to this include and to overwrite its definition from within layouts which inherit from this layout.
layout (string, optional) : References a layout by its name which should be included. If this attribute is defined, no attribute codetemplate/code can be defined.
template (uri, optional) : Defines the path of a template to include here. If this attribute is defined, no attribute codelayout/code can be defined.
<property>Defines a simple property that can be used to parameterize a template.Nonename (string, required) : The name of the property.
value (string, optional) : The value of the property.
<content>Defines the content to be loaded for a certain layout. This is part of Contentwork.Nonename (string, required) : The name of the content definition.
type (string, required) : Defines the Content Provider to be used.
def (string, optional) : Refers to a global content definition. If this attribute is used, name and type are not allowed anymore.