Public Method Details |
XTPL
|
public void XTPL( )
|
|
Constructor: creates new XTPL object.
It turns GZIP output compression on if XTPL_GZIP constant is true.
Example:
<?
define('XTPL_GZIP', true);
$page = new XTPL();
?>
|
Returns |
void
|
|
Start
|
public void Start( [ boolean $gzip ] )
|
|
Starts output buffering. You may control GZIP comperession of the ouput by the argument.
Output buffering allows you to send any headers, cookies and use session_ functions untilthe buffer is flushed. It also allows you to use GZIP output compression which helps tocompress the page size if the browser supports the compression (or the content is sentin standard way if GZIP compression is not supported).
Example:
<?
$page = new XTPL();
$page->Start(true);
$page->Parse('tpl/template.tpl');
$page->End();
?>
|
Parameter |
|
boolean |
$gzip |
= >>false<< |
|
Output ZLib compression |
|
Returns |
void
|
|
Flush
|
public void Flush( )
|
|
Immediately flushes the output buffer.
Example:
<?
$page = new XTPL();
$page->Start();
$page->Parse('tpl/template.tpl');
// flushing the buffer before another template is parsed
$page->Flush();
$page->Parse('tpl/another.tpl');
// End output buffering
$page->End();
?>
|
Returns |
void
|
|
End
|
public void End( )
|
|
Flushes the output buffer and switches output buffering off.
Example:
<?
$page->End();
// Now printing immediately
echo 'Hi, can you see this?';
?>
|
Returns |
void
|
|
GZIP
|
public bool GZIP( [ string $value ] )
|
|
Sets the value of output buffer GZIP compression to $value if it is defined.
Otherwise returns current value of output buffer ZLib compression.
Example:
<?
$current_value = $page->GZIP();
if(!$current_value) $page->GZIP(true);
?>
|
Parameter |
|
|
Returns |
bool
|
|
Assign
|
public void Assign( string $name, mixed $value )
|
|
Assigns a new private XTPL variable.
When XTPL meet {$var} sequence it first looks for the replacement inthe private section. If the variable doesn't exist in the private sectionthen XTPL searches for it in the global scope.
Example:
<?
$id = 25;
$page->ParseStr('id is {$id}');
// 25 is printed
$page->Assign('id', 10);
$page->ParseStr('id is {$id}');
// 10 is printed
?>
|
Parameter |
|
|
|
|
$value |
|
|
Value of the variable to assign |
|
Returns |
void
|
|
Unassign
|
public void Unassign( string $name)
|
|
Removes the variable from the private assigned list. Unassignes the variable which has been
assigned by XTPL::Assign() method.
|
Parameter |
|
|
Returns |
void
|
|
ParseStr
|
public void ParseStr( string $content )
|
|
Parses string and sends result to output. You may use this function to parse the strings
with XTPL syntax directly but it is not recommended.
|
Parameter |
|
|
Returns |
void
|
|
Parse
|
public void Parse( string $filename )
|
|
Parses the template file.
Example:
<?
$page->Parse('template.tpl');
?>
|
Parameter |
|
|
Returns |
void
|
|