Templates

Template in this system is an html (or xhtml, or whatever (must be text)) document with special tags, that instruct the system what to do (eg. write/remove text at some spot, check a condition, etc.).

The location/name of the template file is specified in configuration. This is how a simple xhtml template looks like (if you download this CMS, you'll find the template of this website):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
 <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
 <title><val MAIN_TITLE></title>
</head>
<body>
<h1><val MAIN_TITLE></h1>
<hr />
<for AR in ARTICLES>
<div>
<h2><val AR.title></h2>
<val AR.body>
</div>
</for>
</body>
</html>

Syntax

<block VARIABLE>TEXT</block>
Text TEXT is assigned to variable VARIABLE, and then this construct is replaced with an empty string.
<for I in VARIABLE>TEXT</for>
If VARIABLE is an array or a structure, this construct is replaced with as many copies of TEXT as there are items in it, and every I is replaced with VARIABLE.current_index. Also every I_CNT is replaced with current iteration number, starting with 1. If VARIABLE is not an array nor a structure, this construct is replaced with an empty string.
<val VARIABLE>
This construct is replaced with value of variable VARIABLE.
<count VARIABLE>
If VARIABLE is an array or a structure, this construct is replaced with number of items in it, otherwise it's replaced with '0'.
<if 'VALUE' /EXPRESSION/>TEXT</if>
If text VALUE matches regular expression EXPRESSION, this construct is replaced with text TEXT, if not, it's replaced with an empty string.

Template is processed in the same order as it is given in above list i.e. when processing, for example, if statements, val statements will already be processed and so on.

It is case sensitive.

The depth of loops inside of loops inside of loops, ifs inside of ifs and other things is unlimited.

Variables

Variable names must contain only uppercase and lowercase letters, numbers and _ symbols. Indexes of arrays and structures are seperated with dots. There are three types of variables:

Text
These are simple variables that carry a text value.
Arrays
These are ordered lists of variables of any type. Indexes are numbers starting with 0.
Structures
These are much like arrays, only not sorted and indexes are names, constructed the same way as variable names.

Predefined variables

Apart from variables gathered from content, there are some defined by system:

Name Type Description
LANG text Indicates current language code (in this case LANG = 'en').
LANGS array contains text variables that contain codes of all languages the site is available in (in this case LANGS = ['en', 'lt']).
PAGE structure contains variables of various types which contain the information about the current page. In this case:
  • PAGE.name = 'doc-template' (name of the page)
  • PAGE.link = 'doc-template.html' (link to the page)
  • PAGE.current = 'true' ('true', if this page is current, otherwise 'false')
  • PAGE.inpath = 'true' ('true', if this page is in path, otherwise 'false')
  • PAGE.subpages = [] (an array that contans structures of type PAGE that contain information about subpages of this page)
This structure also contains attributes defined in content.
PAGES array contains structures of type PAGE that contain information about root pages of the site.
PATH array contains structures of type PAGE that contain information about pages that are in the current path from the root page to the current one.
ENCODING text encoding used in the site (specified in the configuration; in this case ENCODING = 'UTF-8')
POWERED text contains a link to the homepage of this CMS, title and version (look at the bottom of this page). You can put this link on your websites if you wish :-)