Guide: Templates

tracend edited this page Jan 2, 2012 · 10 revisions

In the development world, the name "template" is used in a number of different ways. In KISSCMS templates are the different layouts a website has. They are strictly tied to the markup structure rather than how a website looks, also know as theme.

Generally a user expects only one theme for every website, so to keep the web root clean from files that are not used, mutli-theme support is considered out of scope. In brief, all templates have the same theme and thus use the same assets folder.

Note that the assets folder should only contain files related with the theme and not content files. All content media files (audio,images,videos) live in their own "media" folder in the web root.

The Template() class

This class is responsible of loading the right template file and has three main methods exposed to display content in a template - head(), body() and foot()


This generates the content for the head tag - meta tags, links to css and more. All controllers/plugins that have a head.php view will be compiled and output through here.


The body() method generates the main content area, looping through all the data sets, gathered by the controller, while applying the view individually selected for each one.


Not to be confused with the footer tag , here is where all the script files are included. As with the head() method, all loaded controllers and plugins that have a foot.php view will be compiled and displayed here.


Adding new templates is as simple as creating new files in the "html/template/" folder. They will appear automatically when you are editing a page, where you'll have the opportunity to pick a different template for every page.

Some controllers may require a special template - to automate that requirement, if a template has the same file name as the controller (ex. archives.php), it will automatically become the selected tempalte for that controller.