repeatable blocks
| From: | messju mohr | Date: | Sun, 20 Apr 2003 13:32:58 +0000 |
| Subject: | repeatable blocks | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-1228@lists.php.net to get a copy of this message | ||
hello smarty-dev,
i added a new (4th) parameter to block-functions recently. the
parameter is boolean, called $repeat and passed by reference to the
function.
so the function prototype to reads now
function smarty_block_foo($params, $content, &$smarty, &$repeat)
you shouldn't notice any difference in the behaviour of your
block-functions regardless wether you use the old or the new
prototype. if you see a difference, please report this as a bug to
me. :)
$repeat is set to true on the first call to your block-function.
$repeat is set to false on any subsequent call to your block-function
this is nothing new, one could also say:
$repeat = !isset($content)
but since the parameter is passed by reference it can be maninpulated
by your block-function-plugins.
by setting $repeat inside your block-function to true, you can tell
smarty to "repeat" the block. that is: call the block-function another
time with the content between {foo}...{/foo} evaluated another time
and assigned to the $content-parameter. as a special case you can also
set $repeat to false on the very first-call to you block-functions, to
make the block between {foo}...{/foo} not evaluated at all. that's all
behind it.
i hope you like it. report if you encounter problems, but give also
feedback, if you have useful applications for it :)
greetings
messju