Documentation
Tutorials
Using the Smarty template engine
Smarty is a fully featured template engine developed separately from Vigilante. To learn more about how to use Smarty, visit http://smarty.php.net/.
To create a Smarty object, call the Smarty()
function at the top of your page. The object is assigned to the reserved
variable $smarty.
Vigilante does not use Smarty's default file paths to store
its libraries, so it is recommended to initialize a Smarty object with the Smarty()
function. If you want to assign a Smarty object to another variable, create a
new object named Smarty_Extended. You can
also simply assign a variable of your own choosing to the $smarty
variable.
Example 2-7-1
// Reassign the reserved variable $smarty to one of your choosing.
Smarty();
$page = $smarty;
// Assign your variable to Vigilante's extended Smarty class.
$page = new Smarty_Extended;
// Calling the default Smarty class will cause errors in Vigilante.
$page = new Smarty;
Vigilante includes the following set of default template files:
global_header.tpl
Use this template to store the top portion of your HTML source code.global_footer.tpl
Use this template to store the bottom portion of your HTML source code.global_page.tpl
This template concatenates global_header.tpl, global_footer.tpl and a content template passed to Smarty from your PHP scripts.root_index.tpl
Use this template to store the default page of your site.
To simplify template maintenance, create separate templates
to store your content, independent of any header or footer layout. When your
script is ready to pass its data to Smarty, assign the name of a template to
the variable $content_template and
display global_page.tpl.
Example 2-7-2
include("$DOCUMENT_ROOT/includes/common.php");
//Initialize the Smarty object
Smarty();
[. . . multple Smarty assignments . . .]
$smarty->assign("content_template", "template_file.tpl");
$smarty->display("global_page.tpl");