Re: [SMARTY] dynamic inserts

From: Date: Thu, 12 Dec 2002 14:19:47 +0000
Subject: Re: [SMARTY] dynamic inserts
References: 1 2  Groups: php.smarty.general php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6767@lists.php.net to get a copy of this message
M Mohr wrote:
maybe it should. it doesen't, but smarty would try to cache the foreach-loop around your inserts, which is maybe not what you want anyway. what about moving the foreach inside your insert-function?? for example (not testet, but should show what i mean): function insert_box($params, &$smarty) { foreach ($params['box'] as $box) {
      $fun = 'insert_'.$box;
      $fun($params, &$smarty);
} } which is called as {insert name=box box=$box} of course you should not try to add a $box[] = 'box' to your array, since you would have built an endless recursion. :) have fun messju
What you suggests works great in my case, however it is worth noting this one caveat for other users. Smarty seems to cache the parameters passed to insert, so that if which boxes you have changes (not the content of the boxes, which would come from output of the insert), it will not be reflected until the cache gets flushed. I hope that made sense to everyone. ~Paul -- Paul Lockaby paul@dostuff.net http://www.dostuff.net

« previous php.smarty.general (#6767) next »