Re: [SMARTY] Recursion, include, and {section}
| From: | Monte Ohrt | Date: | Tue, 30 Jul 2002 21:27:56 +0000 |
| Subject: | Re: [SMARTY] Recursion, include, and {section} | ||
| References: | 1 2 3 4 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5521@lists.php.net to get a copy of this message | ||
An alternate method, do the recursion in PHP and assemble an array to assign to the template. Give each row a depth value. Use one {section} loop in Smarty and use the depth to figure out the left justification for each line. I use this method because it lets the template handle presentation of data and not bother with how it's related to itself.
Monte
Ken Yarnall wrote:
On Tue, 30 Jul 2002 22:17:35 +0200 Bertrand DUNOGIER <bdunogier@wanadoo.fr> wrote:-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.KY> Problem is, the template contains a named {section}, and KY> the recursive include is inside that {section}. This results in KY> nested sections with the same name. This is futzing up the KY> loops, as the Smarty manual predicts. I managed to fix this using foreach and a local variable in my{include}. Something like: {foreach from=$TREE_ARRAY item=TREE} ... {include file=$SELF TREE_ARRAY=$TREE_ARRAY.tree} ... {/foreach} ($TREE_ARRAY.tree contains each time exactly the same structure, of course)I'll try it, but it seems on its face to be no different. The manual says that nested {foreach} loops need distinct names, too, and you haven't done that here. Ken