TinyButStrong - the PHP Template Engine
Categories > TinyButStrong general >

Heirachical menu

By: Jared
Date: 2009-08-14
Time: 23:13

Heirachical menu

Hi,

I'm working on a nested list, and am wondering if this looks ok? It's not working as I would expect. The third level is not getting generated. Any suggestions?

The HTML:
<ul id='nav'>
  <li>CURLOC
    <ul>
      <li><a href='#'>[curloc.curloc;block=li]</a>
        <ul>
          <li><a href="#">[sub1.Sub1Location;block=ul;p1=[curloc.$];magnet=ul]</a>
            <ul>
              <li><a href="#">[sub2.Sub2Location;block=ul;p1=[sub1.$];]</a></li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

The array:
Array
(
    [A1] => Array
        (
            [curloc] => LSBF
            [Sub1Location] => Array
                (
                    [B1] => Array
                        (
                            [K1] => A1
                            [K2] => B1
                            [Sub1Location] => OFFICE #109
                            [Sub2Location] =>
                        )
                    [B2] => Array
                        (
                            [K1] => A1
                            [K2] => B2
                            [Sub1Location] => OFFICE #222
                            [Sub2Location] => Array
                                (
                                    [B3] => Array
                                        (
                                            [K1] => A1
                                            [K2] => B2
                                            [K3] => B3
                                            [Sub2Location] => ATTACHED TO SSA PC
                                        )

                                )

                        )
    [A2] => Array
        (
            [curloc] => MK
            [Sub1Location] => Array
                (
                    [B3] => Array
                        (
                            [K1] => A2
                            [K2] => B3
                            [Sub1Location] => MK SUMMIT
                            [Sub2Location] =>
                        )

                )

        )
)

The script:
$x = $menu->populateDrops();
$y = 'x[curloc][%p1%][Sub1Location]';
$z = 'x[curloc][%p1%][Sub1Location][%p1%][Sub2Location]';
$tbs->MergeBlock('curloc','array',$x['curloc']);
$tbs->MergeBlock('sub1','array',$y);
$tbs->MergeBlock('sub2','array',$z);
By: TomH
Date: 2009-08-15
Time: 08:21

Re: Heirachical menu

Can't answer your question, but...

There's a prototype of my hierarchical menu system that might be of some value to you here http://tomhenry.us/tbs3/ (see the first prototype TBS application) source code and db layout included there.

The primary reason I developed it was to provide hierarchical menus without the overhead of sub-queries in the process.

Hope that helps,
TomH
Admin mode