Getting started
All templates in Lightnote CMS are based on Smarty Template Engine. If you have no experience with Smarty, I recommend you to read Basic Syntax section before continue.
Page templates are located in templates/pages/[TEMPLATE_NAME] directory. The name of template can contain only alphanumeric characters (a-z, 0-9) and underscore (_).
Page and Content templates must have at least 2 files:
- Configuration file: config.xml (XML configuration file).
- Html template: index.html (Smarty template).
It is very important to save all your template files in UTF-8 encoding to avoid many problems associated with inappropriate display of special characters.
Configuration (config.xml)
You can see a sample configuration file below:
<?xml version="1.0" encoding="utf-8"?>
<PageTemplate>
<friendlyName>My Template</friendlyName>
<author>Dmitry Monin</author>
<version>1.0</version>
<structure>
<column>
<friendlyName>Content</friendlyName>
<width>60%</width>
</column>
<column>
<friendlyName>Sidebar</friendlyName>
<width>40%</width>
</column>
</structure>
</PageTemplate>
| NodeName | Level | Required | Description |
| PageTemplate | 1 | Yes | Root node of Configuration file |
| friendlyName | 2 | Yes | Name of template which will be shown in CMS Backend. |
| author | 2 | No | Author of template. |
| version | 2 | No | Version of template. |
| structure | 2 | Yes | Structure of template. This node contains configuration of how many columns has template. |
| column | 3 | Yes | Must be placed inside of column node. Contains configuration of column. |
| friendlyName | 4 | Yes | Name of column which will be displayed in CMS backend. |
| width | 4 | No | This parameter specifies how wide should be column in CMS backend. It may be needed if template contains more than one column. Value should be in percents. For example: <width>50%</width>. |
| contentTemplates | 2 | No | In case you create your own templates for content elements (text, text&image or rich text editor), you have to specify path to each template file. |
| text | 3 | No | Path to Text element template (relative to page template path). |
| textimage | 3 | No | Path to Text&Image element template (relative to page template path). |
| rte | 3 | No | Path to Rich Text Editor element template (relative to page template path). |
* Name of all nodes are case sensitive.
Template file (index.html)
Template file is a Smarty template and should be named index.html.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$page->GetTitle()}</title>
{$page->GetHeaderHtml()}
</head>
<body>
<h1>{$page->name}</h1>
<div id="menu">{menu from=0 active_class="on"}</div>
<div id="content">{content column=0} </div>
<div id="sidebar">{content column=1} </div>
</body>
</html>
You can use following smarty variables and functions inside your template:
{$page} - Instance of a Page class for current page. Most common fields and methods are:
| Field / Method | Description |
| {$page->id} | Page ID (integer), unique identifier of each page. |
| {$page->name} | Returns name of current page. |
| {$page->GetTitle()} | Returns title of current page (which will be displayed in browser caption). |
| {$page->GetHeaderHtml()} |
Returns data which should be written into page header (between tags). |
| {$page->GetSubPages()} |
Returns an indexed array of subpages. |
{content} - smarty function to render page content.
| Attribute name | Type | Required
|
Default | Description |
| column | Integer | Yes | n / a | Index of column (starting from zero, for example if you have 3 columns in your template, first column will have index 0, second 1, third 2). |
{menu} - smarty function to render menu navigation.
| Attribute name | Type | Required | Default | Description |
| from | Integer (Page Id) / Page object | Yes | n / a | Id of a page, subpages of which should be listed in menu. |
| levels | Integer | No | 1 | Number of menu levels to render for a menu. |
| outer | String | No | li | Html elements outside A element. You can specify more than one element by separating them with | character (e.g. "li|em"). |
| inner | String | No | empty | Html elements inside A tags. You can specify more than one element by separating them with | character (e.g. "b|em"). |
| id_prefix | String | No | menu-item- | Prefix for id attribute applied to each menu item. |
| separator | String | No | empty | Separator between menu items. |
| active_class | String | No | active | Class name of active menu item (applied to outer element). |
| parent_class | String | No | parent-active | Class name of menu item, which is parent to active menu item (applied to outer element). |
| first_class | String | No | first | Class name of first menu item. |
| last_class | String | No | last | Class name of last menu item. |
{assign_menu} - smarty function to assign array of sub pages (instances of type Page) to specified variable for further use in your template (for example to create menu with specific html code).
| Attribute name | Type | Required | Default | Description |
| from | Integer (Page Id) / Page object | Yes | n / a | Id of a page, subpages of which should be listed in menu. |
| var | String | Yes | n / a | Variable name. |