Re: [SMARTY] dynamic creation of array
| From: | Manfred Stienstra | Date: | Fri, 22 Nov 2002 09:54:15 +0000 |
| Subject: | Re: [SMARTY] dynamic creation of array | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6502@lists.php.net to get a copy of this message | ||
On Friday 22 November 2002 08:33, Tim Burden wrote:
> Do an array of the arrays and loop through that. Pass one big array to
> Smarty, section it, then foreach the subarrays. I think.
You can't handle arbitrarily deep nested arrays in smarty because you can't
recursively loop through it. My solution is to just make a flat array with
the depth in it:
node
node
node
node
node
node
node
becomes
node, 0
node, 1
node, 1
node, 0
node, 1
node, 2
node, 2
You'll have to do some smarty things with this in smarty.
The other options is a nested array and writing a function or modifier to
display it.
Manfred
>
> I am working on a tree menu program. Depending on the sub nodes for each
> node and their subnodes..so on.. i have to retrive from database. Now i
> will have to send it to smarty. In section how i will manipulate them.
> Because i do not know.. how many arrays i gonna create. Anybody can give me
> suggestions?
>
> S.Karthikeyan
> Lister Technologies Pvt Ltd
> #235, V.M Street,
> Mylapore,
> Chennai - 600 004
> India