Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

PHP: Nested repeat region in nested repeat region

New Here ,
Jun 23, 2006 Jun 23, 2006
Does anyone know how to this:

I wanna have nested repeat region in repeated region. Example

Parent Category
Category name
Category name
Category name

Parent Category
Category name
sub category name
sub category name
sub category name

Category name
Category name
sub category name
sub category name
sub category name

Parent Category
Parent Category
Parent Category

Can anyone help me with this?

Thanks in advance.
TOPICS
Server side applications
836
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2006 Jun 23, 2006
dreamworms wrote:
> I wanna have nested repeat region in repeated region.

I'm not saying it's necessarily the best way to do it, but this is
certainly one way. The categories are stored as a multidimensional,
associative array. Each element needs to be an array, even if it's
empty. The recursive function displayCats() then loops through the whole
thing and produces the nested results you seek.

<?php
$cats = array('Top Level 1' => array(
'sub a' => array(), 'sub b' => array(), 'sub c' => array()),
'Top Level 2' => array(
'sub d' => array(
'sub sub a' => array(), 'sub sub b' => array()),
'sub e' => array(
'sub sub c' => array(), 'sub sub d' => array()),
'sub f' => array(
'sub sub e' => array(), 'sub sub f' => array(), 'sub sub g' =>
array())),
'Top Level 3' => array(),
'Top Level 4' => array(),
'Top Level 5' => array());

function displayCats($array) {
echo "<ul>\n";
foreach ($array as $key => $value) {
echo "<li>$key</li>\n";
if ($value) {
displayCats($value);
}
}
echo "</ul>\n";
}

displayCats($cats);
?>

--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2006 Jun 23, 2006
LATEST
Tom Muck has a free extension that will do what you require:
http://www.tom-muck.com/extensions/help/simulatednestedregion/

--
Dave Buchholz
I-CRE8
www.i-cre8.co.uk


"dreamworms" <dreamworms@siteatelier.com> wrote in message
news:e7gacv$fc5$1@forums.macromedia.com...
Does anyone know how to this:

I wanna have nested repeat region in repeated region. Example

Parent Category
Category name
Category name
Category name

Parent Category
Category name
sub category name
sub category name
sub category name

Category name
Category name
sub category name
sub category name
sub category name

Parent Category
Parent Category
Parent Category

Can anyone help me with this?

Thanks in advance.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines