Re: [SMARTY] Multi-arrays in Sections
| From: | M Mohr | Date: | Fri, 14 Feb 2003 08:12:51 +0000 |
| Subject: | Re: [SMARTY] Multi-arrays in Sections | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-7754@lists.php.net to get a copy of this message | ||
On Thu, Feb 13, 2003 at 06:14:40PM -0600, Greg Klaus wrote:
> 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 would definately recommend this way: a flat array, each element
knows it's depth and maybe it's parent.
> I guess I'm asking if {section}s can be used in a re-entrant fashion as
> functions within PHP are.
i don't think they can.
> If I'm blind to the obvious solution, forgive me. I suffer from ID10T
> errors from time to time.
>
> Any help is appreciated...