Add method assignAll() to pageBuilder to assign an array of data
This commit is contained in:
parent
890afc32f7
commit
1c2fdb98b1
1 changed files with 23 additions and 0 deletions
23
index.php
23
index.php
|
@ -637,6 +637,29 @@ public function assign($what,$where)
|
|||
$this->tpl->assign($what,$where);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign an array of data to the template builder.
|
||||
*
|
||||
* @param array $data Data to assign.
|
||||
*
|
||||
* @return false if invalid data.
|
||||
*/
|
||||
public function assignAll($data)
|
||||
{
|
||||
// Lazy initialization
|
||||
if ($this->tpl === false) {
|
||||
$this->initialize();
|
||||
}
|
||||
|
||||
if (empty($data) || !is_array($data)){
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assign($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Render a specific page (using a template).
|
||||
// e.g. pb.renderPage('picwall')
|
||||
public function renderPage($page)
|
||||
|
|
Loading…
Reference in a new issue