\SmartTemplate

SmartTemplate Class

'Compiles' HTML-Templates to PHP Code

Usage Example I:

$page = new SmartTemplate( "template.html" ); $page->assign( 'TITLE', 'TemplateDemo - Userlist' ); $page->assign( 'user', DB_read_all( 'select * from ris_user' ) ); $page->output();

Usage Example II:

$data = array( 'TITLE' => 'TemplateDemo - Userlist', 'user' => DB_read_all( 'select * from ris_user' ) ); $page = new SmartTemplate( "template.html" ); $page->output( $data );

Summary

Methods
Properties
Constants
SmartTemplate()
set_templatefile()
add_value()
add_array()
assign()
append()
result()
output()
debug()
use_cache()
cache_callback()
mtime()
$reuse_code
$template_dir
$temp_dir
$cache_dir
$cache_lifetime
$cache_filename
$tpl_file
$cpl_file
$data
$parser
$debugger
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$reuse_code

$reuse_code : 

Whether to store compiled php code or not (for debug purpose)

Type

$template_dir

$template_dir : 

Directory where all templates are stored Can be overwritten by global configuration array $_CONFIG['template_dir']

Type

$temp_dir

$temp_dir : 

Where to store compiled templates Can be overwritten by global configuration array $_CONFIG['smarttemplate_compiled']

Type

$cache_dir

$cache_dir : 

Temporary folder for output cache storage Can be overwritten by global configuration array $_CONFIG['smarttemplate_cache']

Type

$cache_lifetime

$cache_lifetime : 

Default Output Cache Lifetime in Seconds Can be overwritten by global configuration array $_CONFIG['cache_lifetime']

Type

$cache_filename

$cache_filename : 

Temporary file for output cache storage

Type

$tpl_file

$tpl_file : 

The template filename

Type

$cpl_file

$cpl_file : 

The compiled template filename

Type

$data

$data : 

Template content array

Type

$parser

$parser : 

Parser Class

Type

$debugger

$debugger : 

Debugger Class

Type

Methods

SmartTemplate()

SmartTemplate(string  $template_filename = '') 

SmartTemplate Constructor

Parameters

string $template_filename

Template Filename

set_templatefile()

set_templatefile(  $template_filename) 

Parameters

$template_filename

add_value()

add_value(  $name,   $value) 

Parameters

$name
$value

add_array()

add_array(  $name,   $value) 

Parameters

$name
$value

assign()

assign(string  $name, mixed  $value = '') 

Assign Template Content

Usage Example: $page->assign( 'TITLE', 'My Document Title' ); $page->assign( 'userlist', array( array( 'ID' => 123, 'NAME' => 'John Doe' ), array( 'ID' => 124, 'NAME' => 'Jack Doe' ), );

Parameters

string $name

Parameter Name

mixed $value

Parameter Value

append()

append(string  $name, mixed  $value) 

Assign Template Content

Usage Example: $page->append( 'userlist', array( 'ID' => 123, 'NAME' => 'John Doe' ) ); $page->append( 'userlist', array( 'ID' => 124, 'NAME' => 'Jack Doe' ) );

Parameters

string $name

Parameter Name

mixed $value

Parameter Value

result()

result(array  $_top = '') : string

Parser Wrapper Returns Template Output as a String

Parameters

array $_top

Content Array

Returns

string —

Parsed Template

output()

output(array  $_top = '') 

Execute parsed Template Prints Parsing Results to Standard Output

Parameters

array $_top

Content Array

debug()

debug(array  $_top = '') 

Debug Template

Parameters

array $_top

Content Array

use_cache()

use_cache(  $key = '') 

Start Ouput Content Buffering

Usage Example: $page = new SmartTemplate('template.html'); $page->use_cache(); ...

Parameters

$key

cache_callback()

cache_callback(string  $output) : string

Output Buffer Callback Function

Parameters

string $output

Returns

string —

$output

mtime()

mtime(string  $filename) : mixed

Determine Last Filechange Date (if File exists)

Parameters

string $filename

Returns

mixed