Table of Contents
Introduction

In TGPX template system is very powerful and allows you to create nearly any type of design for your TGP and other script generated pages. The template system is also used in the e-mail messages that the software sends, so you can control the content of those messages as well. This document will give you an overview of the basic template features you will need to understand.

Basic Syntax

With the TGPX template system, all template tags are enclosed within the delimiters { and }. All content outside of delimiters is displayed as static content, or unchanged. When the TGPX template parser encounters template tags, it attempts to interpret them, and displays the appropriate output in their place.

Comments

Template comments are surrounded by asterisks, which are in turn surrounded by the delimiter tags like so: {* this is a comment *} Template comments are NOT displayed in the final output of the template, unlike <!-- HTML comments --> these are useful for making internal notes in the templates which no one will see in the generated output. Unlike the majority of the template commands, template comments may span multiple lines, which means the beginning {* delimiter and ending *} delimiter are not required to be on the same line in the template code.

Variables

Template variables start with the dollar sign ($) and can contain numbers, letters and underscores like so: {$password} {$gallery.gallery_url} {$partner.username} When a template variable is encountered by the template parser, the entire template tag (including delimiters) is replaced by the value of that variable. Each of the templates will have different variables that you can use within them, so be sure to review the TGP Page Templates, Script Page Templates and E-mail Templates sections of the manual to find out what variables are available in each template.

Variable Modifiers

In addition to simply displaying variables, you can also apply modifier functions to them. This is useful for formatting purposes, for example, when displaying a date you can specify the format that the date should appear in. Variable modifiers follow the variable name and are separated from it by a | character like so: {$gallery.description|htmlspecialchars} In the example above the PHP function htmlspecialchars is applied to the {$gallery.description} variable before it is displayed in the template. You can use any of the built in PHP functions as long as it takes the variable you specified as the first parameter.

For security reasons, all data provided by users should be passed through a formatting function before it is displayed. For the majority of the user data, it should be passed through the htmlspecialchars function to prevent the possibility of them inserting malicious HTML or JavaScript code into the data they submit.

It is also possible to specify additional function arguments with the modifiers. Function arguments will come after the variable modifier and will be separated by :: delimiters. So, for example, if you wanted to use the PHP function number_format() you would do that like so: {$variable|number_format::2::'.'::','} This would call the number_format PHP function with the arguments like this: number_format($variable, 2, '.', ',') TGPX includes some builtin template modifiers, which are described below: Functions

Function tags appear much like variable tags, but do not start with a dollar sign. These template tags will contain a function name followed by optional function attributes like so: {function attribute1='value1' attribute2='value2'} Some functions are block functions which have both an opening and closing tag. All of the HTML code that is inside the opening and closing tags will be processed by these functions. Block functions look like this: {function attribute1='value1' attribute2='value2'} Some HTML code or other template values {/function} The template system provides some stock functions which are available in all templates, and some custom functions which are only available in specific templates. The Stock Functions are described in this section of the manual. Custom functions will be listed in the TGP Page Templates, Script Page Templates and E-mail Templates sections of the manual where appropriate.

Stock Functions

The TGPX template system offers several stock functions that can be used in any of the software templates. These stock functions are described here.