home    download    forum    manual    awards    faq    bugs    links

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.

assign

Assign a value to a variable.

Description

assign ( string [blockname.]variablename, mixed value )
assign ( Array( [blockname.]variablename => value ) )

The default value of value is ''.



See also: assignGlobal(), getVarValue(), and showUnAssigned().


Example 1.
simple.tpl
<html>
<head>
  <title>Simple Template Example</title>
</head>
<body>
  <H2>Welcome {name}!</H2>
</body>
</html>

myscript.php
<?php
include_once( "./class.TemplatePower.inc.php" );

$tpl = new TemplatePower( "./simple.tpl" );
$tpl->prepare();

$tpl->assign( "name", "Ron" );

$tpl->printToScreen();
?>

Examples of the assign function
$tpl->assign( "name", "Ron" );
$tpl->assign( Array( product_id  => $pid,
                     productname => $pname ));


Variables and Blocks

Each variable is a child of a parent block. Even in example 1, where no block is defined, the variable name has a parent block. The parent block of name is _ROOT, this is the default block if a variable has no user-defined parent-block.

Variables can also be defined together with the parent-blockname, in the format of 'blockname.variablename'.

$tpl->assign( "_ROOT.name", "Ron" );
$tpl->assign( "book.title", "Core PHP Programming" );


 

 
CopyRights © 2001-2009 Ron. P.J. Velzeboer.