PHP Bulletin Board Home
News About Home
Features of phpBB Test drive phpBB Downloads Support for phpBB The phpBB Community Styles for customising phpBB 3rd party modifications to phpBB

Support Home | Knowledge Base Home | Submit Article | Search Articles | Browse Articles
 About templates 
Description: Basic info on how to write phpBB2.0.x templates
Author: Davidls
Date: Sat Jan 25, 2003 10:53 am
Type: Info
Keywords: template,template class,template basics,templating,templates
Category: MODifications
Templating Basics

Syntax

Apart from what you may think, the phpBB2 templating syntax is actually very easy. The amount of variables on any one page may seem daunting at first, but really each one only represents piece of information. Together with the html around them they produce the interface and information that phpBB2 presents to you. The phpBB2 variable system is very easy to pickup because every variable is held inside braces ( {Braces} ). Variables are always in upper-case, because this is how the phpBB2 template engine processes them. For you to easily identify what each variable means, the system has the following standards:


  • The prefix U_ is a URL variable. These should always be used instead of directly linking to the php page, to allow phpBB2 to control the URI session ids.
  • The prefix L_ is a language variable. These should always be used instead of directly using English to allow to multi-lingual boards to use the template without confusion.
  • The prefix S_ is a form variable. These variables control everything about a form, from the action, to form fields such as hidden fields and select boxes. Not all form fields are represented by a variable, only fields which need to be controlled by phpBB2.
  • The prefix T_ is a theme variable. These variables represent database information about the current theme. These should be used if you want people to be easily change the colour scheme of your template without having to edit the template itself.
  • The suffix _IMG is an image variable. These images a controlled by the phpBB2 code itself. All these images however are specified in the template config file.


Switches and Loops

These are one of the most important part of the phpBB2 templates. Switches are however different to loops. Switches hided/show information depending on circumstances, and Loops, loop through information such as forum rows on the index_body.tpl page. Switches and loops are held inside HTML comments:

<!-- BEGIN name -->
<!-- END name -->

Switches

Switches hide/show information on certain circumstances. The variable contents of switches do not get derived from the switch name. Switches usually contain the word switch or toggle. Switches and loops however are case sensative, and are usually only in lower case.

Loops

Loops are different to switches, in that they always show information. Loops are designed so that the phpBB2 code can loop through the contents of the loop for every field in the database, for example showing every single forum under every single category. Variable names contained within, however are derived from the loop name, for example: {catrow.forumrow.FORUM_DESC} . Each loop the variable is contained within, it pickups up another variable which is the case the loop name itself is in. The variable name is still upper-case as seen in the above sample from index_body.tpl . This above example is held within two loops, and each variable is separated by a dot (".").

Username: Password:
News | Features | Demo | Downloads | Support | Community | Styles | Mods | Links | Merchandise | About | Home
 © Copyright 2002 The phpBB Group.