-
Improvement
-
Resolution: Fixed
-
Minor
-
3.1.0-dev
-
None
Currently assign_block_vars() is used to assign block template loops which requires to be called within foreach/for/etc loop to assign the whole block, like that:
foreach ($block_arrays as $block_array)
|
{
|
$template->assign_block_vars('blockname', array(
|
'TOKEN_1' => $block_array[0],
|
'TOKEN_2' => $block_array[1],
|
'TOKEN_3' => $block_array[2],
|
));
|
}
|
This makes it hard to change the data assigned to the template loop when it come to extensions, because you either have to create event within the PHP loop to add/change $block_array key=>value pairs, or to use tricks with alter_block_array() construction which is not even possible within event.
The suggestion is to add one more (wrapper) template method which can take the whole 2-dimensional $block_arrays array as a parameter, which (the array) can be passed to event before being assigned to template block loop, like following:
extract($phpbb_dispatcher->trigger_event('core.modify_template_block_vars', compact('$block_arrays')));
|
$template->assign_block_vars_array('blockname', $block_arrays);
|
The wrapper function itself would be looking like that:
public function assign_block_vars_array($blockname, array $block_vars_array)
|
{
|
foreach($block_vars_array as $vararray)
|
{
|
$this->assign_block_vars($blockname, $vararray);
|
}
|
return true;
|
}
|
This can make the core a little bit more expendable from the point of developing extensions.