Difference between revisions of "Creating templates"
m |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | As you can see in the [[User Guide]] you can create new documents based on | + | As you can see in the [[User Guide]] you can create new documents based on [[Templates]]. But OpenKM offers another feature based in this idea. First of all you need to know the template syntax, which is used by the [http://freemarker.sourceforge.net/ FreeMarker Template Engine]. This engine can be used from making simply variable substitution to loops and other control structure. In this example we use only the basic ones, but you can learn more at [http://freemarker.sourceforge.net/docs/index.html FreeMarker Manual]. |
− | |||
− | |||
OpenKM can handle 3 types of template documents: | OpenKM can handle 3 types of template documents: | ||
− | * [[Creating PDF templates|PDF | + | * [[Creating PDF templates|PDF]] |
− | * [[Creating OpenOffice templates|OpenOffice | + | * [[Creating OpenOffice templates|OpenOffice]] |
− | * [[Creating Text templates|Text]] | + | * [[Creating Text templates|Text]] (This includes other text-based like HTML, for example) |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | [ | + | == To generate fillable content == |
− | + | In order to generate the final document from the template, we need to make an association with [[Property Groups]] and register them in [[Property Groups administration]]. The final document also will be assigned the corresponding property group with the user input values, so you can use them for a future search. The three sample template types we will use this [[Property Groups definition]]: | |
− | |||
− | |||
− | |||
'''PropertyGroups.xml''' | '''PropertyGroups.xml''' | ||
<source lang="xml"> | <source lang="xml"> | ||
<?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||
− | <!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 1 | + | <!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.1//EN" |
− | "http://www.openkm.com/dtd/property-groups- | + | "http://www.openkm.com/dtd/property-groups-2.1.dtd"> |
<property-groups> | <property-groups> | ||
− | <property-group label="Sample | + | <property-group label="Sample Template" name="okg:tpl"> |
− | <input label="Name" name="okp: | + | <input label="Name" name="okp:tpl.name"/> |
− | <input label="Bird Date" name="okp: | + | <input label="Bird Date" name="okp:tpl.bird_date" type="date" /> |
− | <select label="Language" name="okp: | + | <select label="Language" name="okp:tpl.language" type="simple"> |
<option label="Java" value="java"/> | <option label="Java" value="java"/> | ||
<option label="Python" value="python"/> | <option label="Python" value="python"/> | ||
Line 38: | Line 25: | ||
</property-group> | </property-group> | ||
</property-groups> | </property-groups> | ||
+ | </source> | ||
+ | |||
+ | {{Warning|Remember you need to add these in: [[Property Groups]] and register them in [[Property Groups administration]].}} | ||
+ | |||
+ | == OpenKM 5.1 == | ||
+ | In OpenKM 5.1 and older you need to define also the property structure: | ||
+ | |||
+ | '''PropertyGroups.cnd''' | ||
+ | <source lang="xml"> | ||
+ | <okm = 'http://www.openkm.org/1.0'> | ||
+ | <okg = 'http://www.openkm.org/group/1.0'> | ||
+ | <okp = 'http://www.openkm.org/group/property/1.0'> | ||
+ | |||
+ | [okg:tpl] mixin | ||
+ | - okp:tpl.name (string) = '' autocreated | ||
+ | - okp:tpl.bird_date (string) = '' autocreated | ||
+ | - okp:tpl.language (string) = '' autocreated | ||
</source> | </source> | ||
[[Category: Installation Guide]] | [[Category: Installation Guide]] |
Latest revision as of 14:35, 2 April 2013
As you can see in the User Guide you can create new documents based on Templates. But OpenKM offers another feature based in this idea. First of all you need to know the template syntax, which is used by the FreeMarker Template Engine. This engine can be used from making simply variable substitution to loops and other control structure. In this example we use only the basic ones, but you can learn more at FreeMarker Manual.
OpenKM can handle 3 types of template documents:
- OpenOffice
- Text (This includes other text-based like HTML, for example)
To generate fillable content
In order to generate the final document from the template, we need to make an association with Property Groups and register them in Property Groups administration. The final document also will be assigned the corresponding property group with the user input values, so you can use them for a future search. The three sample template types we will use this Property Groups definition:
PropertyGroups.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.1//EN"
"http://www.openkm.com/dtd/property-groups-2.1.dtd">
<property-groups>
<property-group label="Sample Template" name="okg:tpl">
<input label="Name" name="okp:tpl.name"/>
<input label="Bird Date" name="okp:tpl.bird_date" type="date" />
<select label="Language" name="okp:tpl.language" type="simple">
<option label="Java" value="java"/>
<option label="Python" value="python"/>
<option label="PHP" value="php" />
</select>
</property-group>
</property-groups>
Remember you need to add these in: Property Groups and register them in Property Groups administration. |
OpenKM 5.1
In OpenKM 5.1 and older you need to define also the property structure:
PropertyGroups.cnd
<okm = 'http://www.openkm.org/1.0'>
<okg = 'http://www.openkm.org/group/1.0'>
<okp = 'http://www.openkm.org/group/property/1.0'>
[okg:tpl] mixin
- okp:tpl.name (string) = '' autocreated
- okp:tpl.bird_date (string) = '' autocreated
- okp:tpl.language (string) = '' autocreated