Building a Template
In MachCMS, templates are written in pure HTML. You can add CSS, JavaScript, or whatever else you want.
The dynamic content is defined using directives. The dictionary
definition of directive is, "an official or authoritative instruction."
In a MachCMS template this instruction is defined using an HTML comment. For example when you have this code in the page:
$template->Page_Title = "Page Title";
What this actually does is replace <!--Page_Title--> in the template with "Page Title."
The template class searches for all comments (directives) in the
template and builds an array out of them. Then using the template class
you can set the directives and when the fire() method is initiated the
find and replace is done.
INC:*
This is a special type of directive. The syntax goes like this:
<!--INC:file-->
In case you didn't figure it out, this includes the file, "file.tpl".
Now file.tpl can include another file called anotherfile.tpl like this:
<!--INC:anotherfile-->
You should take notice that the .tpl extension is not included in the INC:. This is intentional.
LINK:*
Another neat type of directive is LINK:. As the name suggests, it
defines a link to a page. For example if you want the link to the page
"HomePage", you would do something like this:
...href="<!--LINK:HomePage-->"...
What is the reason for this directive? We'll blame it on the linkType
setting. With different type of links we need a dynamic way to set
them. So that's what the LINK:* directive is for.
Creating a New Template
- Create a new folder in the templates folder with the name of your
choice. This new folder name is what you use in the template setting in
settings.xml.
- Make a new file named main.tpl. This is where all your HTML and
directives go. You can include other .tpl files. All images, css,
anything that the template uses must abide in this new folder.
- Open settings.xml and change the template setting to the name of your new template folder.