Hi,

I'm trying to create a mod based on the script "infinite depth categories" at
http://www.codeassembly.com/How-to-display-infinite-depth-expandable-categories-using-php-and-javascript
I've been struggling with it for days now without success. I hope you have some time for it and help me.

I would like to print every category names and want to append to them links to every subsequent pages if they have one (to make it clear I simplified my project here, later I want to modify categories to be pages with the links in them).

E.g. I have a menu tree with parent and child members that has the structure:

one
 one one
  one one one
 one two
two
 two one
 two two
three

And this is how I want it with links to subpages:

one <A HREF="one one">one one</A> <A HREF="one two">one two</A>
one one <A HREF="one one one">one one one</A>
one one one
one two
two <A HREF="two one">two one</A> <A HREF="two two">two two</A>
two one
two two
three

I have put them in an array as it is suggested at above website. I had to create "Fake" array index 0 so that "one" starts with key 1. It is not needed when traversing the array.

$menu_array =	Array
(
    0 => Array
        (
            'name' => 'Fake',
            'parent' => -1
        ),

1 => Array
    (
        'name' => 'one',
        'parent' => 0
    ),

2 => Array
    (
        'name' => 'one one',
        'parent' => 1
    ),

3 => Array
    (
        'name' => 'one one one',
        'parent' => 2
    ),

4 => Array
    (
        'name' => 'one two',
        'parent' => 1
    ),

5 => Array
    (
        'name' => 'two',
        'parent' => 0
    ),

6 => Array
    (
        'name' => 'two one',
        'parent' => 5
    ),

7 => Array
    (
        'name' => 'two two',
        'parent' => 5
    ),

8 => Array
    (
        'name' => 'three',
        'parent' => 0
    )

);

Thank you.

    Write a Reply...