TemplatePower manual

Arabic
Deutsch
Dutch
English
Italian
Portuguese (Brazilian)
Russian
Spanish
* Not fully translated yet.
Looking
for the manual in your language? Well, I need translators to
translate the manual to any language. So, if you have some sparetime
please sign up!
Just email to sign up:
rovel999_AT_codocad_DOT_com
If you have signed up you will receive more information about the
translation. |
|
assignGlobal
(TP 2.0+)
Assign a value to all variables with a specific name.
Description
assignGlobal ( string variablename, mixed value )
assignGlobal ( array( variablename => value ) )
The function assignGlobal() gives a default value to all variables, even in child
blocks, with a specific name. This default value can be replaced in each block,
which has a that variable, with the function assign().
Example 1.
img.tpl
<html>
<head>
<title>AssignGlobal Example</title>
</head>
<body>
<img src="{imagedir}/logo.gif">
<!-- START BLOCK : image -->
<img src="{imagedir}/img_{id}.gif">
<!-- END BLOCK : image -->
</body>
</html>
|
myscript.php
<?php
include_once( "./class.TemplatePower.inc.php" );
$tpl = new TemplatePower( "./img.tpl" );
$tpl->prepare();
$tpl->assignGlobal( "imagedir", "images");
for ( $i=1; $i<=10; $i++ )
{
$tpl->newBlock( "image" );
$tpl->assign( "id", $i );
}
$tpl->printToScreen();
?>
|
Examples of the assignGlobal function
$tpl->assignGlobal( "basedir", "/usr/local/apache/www/");
$tpl->assignGlobal( Array( basedir => "/usr/local/apache/www/",
imagedir => "images/" ));
|
|