setGlobalVariable() -- グローバル変数の値を設定する
説明
グローバル変数の値を設定します。グローバル変数は "特別" なもので、
置換が行われた後もクリアされません。また、置換後もブロックを空にしません。
パラメータ
- mixed
$variable
変数名あるいは ('変数名'=>'値') 形式の配列。
- string
$value
$variable が配列でない場合の、変数の値。
注意
この関数は、スタティックにコールする
ことはできません。
|
setCurrentBlock() (Previous)
|
(Next) setOption()
|
|
|
Download Documentation
|
Last updated: Sun, 05 Oct 2008 |
|
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
|
|