setGlobalVariable() -- Sets a global variable value.
Opis
Sets a global variable value. Global variables are "special": they do not get cleared after substitution and do not make blocks not empty if substituted.
Parametr
- mixed
$variable
variable name or array ('varname'=>'value')
- string
$value
variable value if $variable is not an array
Wyjątki
throws no exceptions thrown
Uwagi
Ta funkcja nie może być wywołana
statycznie.
|
setCurrentBlock() (Previous)
|
(Next) setOption()
|
|
|
Download Documentation
|
Last updated: Mon, 02 Jul 2007 |
|
Do you think that something on this page is wrong? Please file a bug report or add a note.
|
| User Notes: |
Note by: shayne.oneill@gmail.com
This is a really good function to know about as it solves a common conundrum.
Oftentimes in a list form you'll get a situation where you have something like (All follows in pseudocode/pseudohtml)
[-- BEGIN block --]
{item1} {item2} {currency}{price}
[-- END block --]
{currency}{total}
Now, you'd itterate that block by doing something like
foreach ($items as $item) {
$template->setvariable(array('item1'=>'$item[item1],'item2'=>$item[item2],'currency'=>'$','price'=>$item[price]))
$template->parseBlock('block')
}
Now if you do a setvariable to get the currency in the currency/total, it'll also mark a new block and you end up with an empty block line.
HOWEVER if you use the setGlobalVariable, it wont unempty the block, thus leaving the table as it should
|
|