Template System Overview
Introduction
The SFTrade template system is very powerful and allows you to create nearly any type of design for the software 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 SFTrade 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 SFTrade 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: {$g_config} {$trade.return_url} {$user.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 other template 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: {$g_stats.i_raw_60|t_tostring} In the example above the SFTrade function t_tostring is applied to the {$g_stats.i_raw_60} 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.

It is also possible to specify additional function arguments with the modifiers. Function arguments will come after the variable modifier and will be enclosed in parenthesis. 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, '.', ',') SFTrade 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. Other functions that are available on specific pages will be covered in the appropriate sections of this manual.
Stock Functions
The SFTrade template system offers several stock functions that can be used in any of the software templates. These stock functions are described here.