Table of Contents

Yes, the templates do have some PHP code in them, but that code is not doing much more than printing (sending) HTML to your browser. So don’t let the PHP code scare you. Do not change the PHP code unless you know what you are doing. Though, you can move a block of code to a different location in the template if you want to rearrange the layout.

Below is short primer about the types of PHP statements you will see in the templates. The primer won’t turn you into a PHP programmer but it will give you insights that allow you to to separate the PHP code from the HTML code as you are viewing a template.

Print statement
Sends the text inside the double quotes to the browser. Example:

print "
<!-- Language select links -->
<p class='tb-center'>$language_links</p>";
Your browser ignores indenting and extra spaces, and doesn't care whether or not multiple tags occur on the same line. But I have taken care to print the HTML in such a manner that if you view it with your browser’s view source commmand, it will be indented and easy to read.

PHP variables
A variable looks like this: $language_links or this $lang['comdisplay6']. The variable contains a value (a piece of information). Think of the variable name as a placeholder. When the script is executed PHP replaces the variable name with the actual contents of the variable.

Most variables in the templates were created by the driver script (the script that is executed just prior to the template script). But some come from the configuration table array $config['entryname'] or the language file array $lang['entryname']. PHP statements use the variables to either decide what action to take or to print the variable to the browser.

If statements
Determines whether or not an action is done, i.e if condition x do y. Example:

if ($x || $y) {	
   print "this text";
Means: if the variable $x has a value OR $y has a value, print to the browser whatever is inside the double quotes. May also be written as:
if ($x || $y) print "this text";
You will also see if statements in this format:
if (condition 1) {
   print "some text";
} elseif (condition 2) {
   print "some different text";
} else {
   print "the default text";
Note the use of the { and } characters. { marks the start of an action and } marks the end of an action. Like HTML, PHP code can be mashed together on one line. But I have used multiple lines and indentation to make the code easier to read.

For statements
Causes something to be done a number of times.

for($counter = 0; $counter < $some_number; $counter++) {
   do something
Means: starting with $counter at zero, while $counter is less than the value in $some_number, do something then increment the counter by 1 and repeat the process.


==  is equal to
!=  is not equal to
<   is less than
>   is greater than
||  OR
&&  AND
=   set the value of the variable on the left to the value of the variable or string on the right

Include statments
Causes another script file to be executed. Examples:

include "filename.php";
Reads in and executes the file named filename.php.
include $config['comments_form_tpl'];
Reads in and executes the file whose name is contained in the $config array entry. In this case, the filename is for the comments form template.