Multi-arrays in Sections
| From: | Greg Klaus | Date: | Fri, 14 Feb 2003 00:14:40 +0000 |
| Subject: | Multi-arrays in Sections | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-7752@lists.php.net to get a copy of this message | ||
This may have already been covered elsewhere, but I'm at a loss to find
the answer.
I am reading a DB table that is a list of categories.
Cat_ID = Actual category identifier
SubCat_ID = This Cat is a SubCat of this identifier.
I am building this so that it can be a list of categories with
'infinite' subcategories.
The problem surrounds being able to present the hierarchy of the
categories in a tree format, similar to what the smarty 'debug.tpl' look
is.
Here is the output of test data in the debug panel:
-----8<-----
Array (1)
0 => Array (7)
Cat_ID => 1
SubCat_ID => 0
Cat_Name => General Category
SubCats => Array (1)
0 => Array (7)
Cat_ID => 2
SubCat_ID => 1
Cat_Name => subcat 1
SubCats => Array (1)
0 => Array (7)
Cat_ID => 3
SubCat_ID => 2
Cat_Name => subcat 2
SubCats => Array (0)
-----8<-----
How should the {section} area be crafted to facilitate this? Is it
possible or should I be looking at passing a single array with a 'level
depth' variable to 'indent' according to the level?
I guess I'm asking if {section}s can be used in a re-entrant fashion as
functions within PHP are.
If I'm blind to the obvious solution, forgive me. I suffer from ID10T
errors from time to time.
Any help is appreciated...
--
Greg Klaus - greg@timeatics.com
TIMEatics - http://www.timeatics.com
voice: 785.456.7600
Nec Mors, Nec Requies. Carpe Noctum!