Creating Text templates
Preliminaries
Section titled “Preliminaries”Register the Metadata group definition at Administration > Metadata.
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 3.10//EN" "http://www.openkm.com/dtd/property-groups-3.10.dtd"><property-groups> <property-group label="Sample Template" name="okg:tpl"> <input label="Name" name="okp:tpl.name"/> <input label="Birth Date" name="okp:tpl.birth_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>In order to create a relation between the template form field and the property group, you have to name them following a naming convention: replace “:” and “.” with “_”. Here you can see the matching between both fields:
| Metadata field name | Template field name | Template field value |
|---|---|---|
| okp:tpl.name | okp_tpl_name | ${okp_tpl_name!} |
| okp:tpl.birth_date | okp_tpl_birth_date | ${okp_tpl_birth_date!} |
| okp:tpl.language | okp_tpl_language | ${okp_tpl_language!} |
Creating the template
Section titled “Creating the template”For this kind of template, we will create an HTML template. This is the template source code:
<html> <body> <h1>Sample template</h1> <table> <tr> <td><b>Name</b></td> <td>${okp_tpl_name!}</td> </tr> <tr> <td><b>Birth Date</b></td> <td>${okp_tpl_birth_date?string("yyyy-MM-dd")!}</td> </tr> <tr> <td><b>Language</b></td> <td>${okp_tpl_language!}</td> </tr> </table> </body></html>