1.2. Template structure

A template set is a collection of files that together form a single template. All template sets are stored in their own subdirectory under the directory {phorum dir}/templates. If we asume that we have three templates default, template1 and template2, then the directory structure for storing these templates would look like this:


{phorum dir}
 |
 +-- templates
    |
    +-- default
    |
    +-- template1
    |
    +-- template2 

Inside these template subdirectories, the files for the templates are stored. There, the the following files can be found:

info.php

This is a PHP file that is used for describing some properties of the template. This file can define the following variables:

  • $name
    Mandatory variable. This variable hold the name that you want to give to the template. This is the name that will be displayed in template selection boxes. The name of the directory for the template will only be used by Phorum internally.
  • $version
    Mandatory variable. This variable holds the version number for your template. It's used so you can track what version of the template is installed for Phorum. You can use any type of version numbering you like. If you do not know what to use, then simply give your first version of the template version 1, the second number 2, and so on.
  • $template_hide
    Optional variable. If set to a true value, the template will be hidden from user select boxes where the end user can choose the template that he wants to use.

Example 1.1. Template information file: $info.php

<?php
// Prevent loading from outside the Phorum application.
if (!defined("PHORUM")) return;

// Template information.
$name = "A brilliant template";
$version = "1.2-beta";
$template_hide = 1;
?> 


.tpl and .php files

These are the files that hold the actual template code. When the Phorum application wants to display a template, it is always referenced by its basename (i.e. without any file extension like .php or .tpl after it). If the file <template basename>.php exists in the template directory, then Phorum will use that file as the template input. Else, <template basename>.tpl will be used.

An example: if Phorum wants to display the "header" template, it will first search for header.php in the template directory. If that file does not exist, it will use header.tpl instead.

PHP files (*.php) contain pure PHP/HTML code. In Phorum template files (.tpl) you can additionally make use of the Section 1.4, “The Phorum template language”.

Using this system, template authors can completely revert to using pure PHP-code for templates, without using the template language at all. The Phorum development team does not recommend doing this. To keep templates simple, always try to stick to the combination of HTML code and the template language.

Other files and subdirectories

In most cases these will be image files which are stored in a subdirectory images of the template. But template authors are free to add whatever subdirectories and files they like to the template directory (e.g. Flash based page components, CSS stylesheets, audio files, JavaScript libraries, etc.).

Combining all this, the full tree for a typical template would look like this:


{phorum dir}
 |
 +-- templates
    |
    +-- templatename
         |
         +-- info.php
         |
         +-- *.tpl
         |
         +-- images
              |
              +-- *.gif, *.jpg, *.png