Categories > TinyButStrong general >

Menu tree

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: tjitte
Date: 2005-12-02
Time: 16:25

Menu tree

First of all thanks for making this template engine. It’s one of the best I’ve tested.

What I would really appreciate is some help with making a menu tree. I just can’t figure it out.

I saw some examples in this forum but for me it’s really important that the page is strict html and that the html is in the template and not generated by a function.

I would like to make a “ul li” structure from the following array.
 
Example array:
$menu[0] = array('pn'=>'menuitem 1','pu'=>'page.html');
$menu[1] = array('pn'=>'menuitem 2','pu'=>'page.html');
    $menu[1]['sub'][1] = array('pn'=>'menuitem 21','pu'=>'page.html');
    $menu[1]['sub'][2] = array('pn'=>'menuitem 22','pu'=>'page.html');
    $menu[1]['sub'][3] = array('pn'=>'menuitem 23','pu'=>'page.html');
        $menu[1]['sub'][3]['sub'][1] = array('pn'=>'menuitem 231','pu'=>'page.html');
        $menu[1]['sub'][3]['sub'][2]  = array('pn'=>'menuitem 232','pu'=>'page.html');
    $menu[1]['sub'][4] = array('pn'=>'menuitem 24','pu'=>'page.html');
$menu[3] = array('pn'=>'menuitem 3','pu'=>'page.html');
$menu[4] = array('pn'=>'menuitem 4','pu'=>'page.html');

Example output:
<ul id="menu">
    <li>menuitem 1</li>
    <li>menuitem 2
        <ul>
            <li>menuitem 21</li>
            <li>menuitem 22</li>
            <li>menuitem 23
                <ul>
                    <li>menuitem 231</li>
                    <li>menuitem 232</li>
                </ul>
            </li>
            <li>menuitem 24</li>
        </ul>
    </li>
    <li>menuitem 3</li>   
    <li>menuitem 4</li>
</ul>

Some conditions:

- The menu needs to be completely dynamic
- The less code in the template the better
- All the html needs to be in the template

I can use all the help I get, so thanks in advance!


Ps. There is one more thing I don’t understand. How do I give arguments back to a function?

in the code:
function test($argument,$argument2){

    if(isset($argument)){
    return 'set';
        elseif(isset($argument)){
    return 'set2';
         }else{
    return 'not set';
    }
}

in the template something like this:
<strong>[var.test(1,0)]</strong>
By: Skrol29
Date: 2005-12-02
Time: 18:40

Re: Menu tree

Hi,

Does you menu has only 3 possible levels (easy to do) ?
Or does it have an unlimited level number (not easy to do) ?

> Ps. There is one more thing I don’t understand.
> How do I give arguments back to a function?

Var fields only support global variables and objets. Not functions.
To call a function, you have to use parameter "onformat" with a function havinf the expected syntax.
By: tjitte
Date: 2005-12-03
Time: 13:05

Re: Menu tree

Hi,

Thx for the reply!

My menu can have max 5 possible levels and this can been defined in the template.

For example, something like this?: 
    <ul id="menu1">
        <li>[menu.pn;block=li]
            <ul id="menu2">
            <li>[menu1.pn;block=li;p1=[menu.$];magnet=ul]
                    <ul id="menu3">
           <li>[menu2.pn;block=li;p1=[menu1.$];magnet;ul]</li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>

I was trying to us a magnet to remove the ul element if there is no value for the li. But this doens't seem te work..

The templates I build are for the grafisch designers they don't know anything about programma stuff so the less code in the template the better. But all xhtml needs to be in the template.

See my first post for the correct html code.

Could you give me a example on how to build a menu like this?

Thx!



By: tjitte
Date: 2005-12-03
Time: 13:40

Re: Menu tree


If possible could you also give me a example on how to use a function with arguments?

Lets say that the menu can start on different levels.
So if I got an array with menu items and I want to start the display on level 2 instead of displaying the intire array.

PHP example:
function level($level){

// here function to only get all menuitems under 'menuitem2'

return $menu;
}


Template example:
[menu;block=li;onformat=level('menuitem2')]











By: Skrol29
Date: 2005-12-05
Time: 02:41

Re: Menu tree

Hello,

To retrieve parameters from a custom "onformat" function, you can use the argument $CurrPrm.
Example:
[menu;block=li;onformat=level;x1='menuitem2']

PHP:
function level($FieldName,&$CurrVal,&$CurrPrm) {
  $lev_name = $CurrPrm['x1'];
  ...
}

I will give to you an example for your dynamic menu soon...
By: Skrol29
Date: 2005-12-05
Time: 11:13

Re: Menu tree

Hello,

Here is an example that works for 3 levels. But you can do the same for 5.
It shows how to use sub-blocks with dynamic queries for Arrays. And how to deals with several parameters for the dynamic queries.

HTML:
<ul>
  <li>[lev1.pn;block=li]
    <ul>
      <li>[lev2.pn;block=li;p1=[lev1.$]]
        <ul>
          <li>[lev3.pn;block=li;p1=[lev1.$];p2=[lev2.$]]
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

PHP:
$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('test.htm');

$TBS->MergeBlock('lev1','array','menu');
$TBS->MergeBlock('lev2','array','menu[%p1%][sub]');
$TBS->MergeBlock('lev3','array','menu[%p1%][sub][%p2%][sub]');

$TBS->Show();

It works with the PHP array you've given.
By: tjitte
Date: 2005-12-05
Time: 12:32

Re: Menu tree

Thanks for the reply & help!

The menu works fine but there is one more problem.
The code needs to be the same as above.

So if the li is empty there is no need to print the ul.
I have tried to use the magnet (magnet=ul) for this but because there is no value for the empty li sublevels, the magnet will not be executed.

example:
[lev2.pn;magnet=ul;block=li;p1=[lev1.$]]

example 2:
<ul>
            <li>menuitem1
            <ul>
                <li>submenu11</li>
            </ul>
            </li>
            <li>menuitem2
            <ul>
                <!--empty so ul can be deleted--->
            </ul>
            </li>
</ul>


Thanks again for your help!












By: Skrol29
Date: 2005-12-05
Time: 13:41

Re: Menu tree

Hep, sorry,

This is more difficult, bu here is a snippet that works:
<ul>
  <li>[lev1.pn;block=li]
    <ul>
      <li>[lev2.pn;block=li;p1=[lev1.$]]
        <ul>
          <li>[lev3.pn;block=li;p1=[lev1.$];p2=[lev2.$]]
          </li>
          <li>[lev3;nodata;block=li][onshow;magnet=ul]</li>
        </ul>
      </li>
      <li>[lev2;nodata;block=li][onshow;magnet=ul]</li>
    </ul>
  </li>
</ul>

Unfortunately, parameter "parentgrp" doesn't work with dynamic queries :(
I will study that deeper for next version.
By: Jared
Date: 2009-08-18
Time: 21:51

Re: Menu tree

I can not get a menu with 4 levels to work following the example given here. Am I doing something wrong?


$menu[0] = array('pn'=>'X','pu'=>'page.html');
$menu[0]['sub'][0] = array('pn'=>'XX','pu'=>'page.html');
$menu[0]['sub'][0]['sub'][0] = array('pn'=>'XXX','pu'=>'page.html');
$menu[0]['sub'][0]['sub'][0]['sub'][0] = array('pn'=>'XXXX','pu'=>'page.html');

$menu[1] = array('pn'=>'Y','pu'=>'page.html');
$menu[1]['sub'][0] = array('pn'=>'YY','pu'=>'page.html');
$menu[1]['sub'][0]['sub'][0] = array('pn'=>'YYY','pu'=>'page.html');
$menu[1]['sub'][0]['sub'][0]['sub'][0] = array('pn'=>'YYYY','pu'=>'page.html');

$tbs->MergeBlock('lev1','array','menu');
$tbs->MergeBlock('lev2','array','menu[%p1%][sub]');
$tbs->MergeBlock('lev3','array','menu[%p1%][sub][%p2%][sub]');
$tbs->MergeBlock('lev4','array','menu[%p1%][sub][%p2%][sub][%p3][sub]');

    <ul>
      <li><a href=''>[lev1.pn;block=li;htmlconv=yes]</a>
        <ul>
          <li><a href=''>[lev2.pn;block=li;p1=[lev1.$];noerr]</a>
            <ul>
              <li><a href=''>[lev3.pn;block=li;p1=[lev1.$];p2=[lev2.$];noerr]</a>
                <ul>
                  <li><a href=''>[lev4.pn;block=li;p1=[lev1.$];p2=[lev2.$];p3=[lev3.$];htmlconv=yes]</a></li>
                  <li>[lev4;nodata;block=li][onshow;magnet=ul]</li>
                </ul>
              </li>
              <li>[lev3;nodata;block=li][onshow;magnet=ul]</li>
            </ul>
          </li>
          <li>[lev2;nodata;block=li][onshow;magnet=ul]</li>
        </ul>
      </li>
    </ul>

outputs:
    <ul>
      <li><a href=''>X</a>
        <ul>
          <li><a href=''>XX</a>
            <ul>

              <li><a href=''>XXX</a>
               
              </li>
            </ul>
          </li>
        </ul>
      </li><li><a href=''>Y</a>
        <ul>
          <li><a href=''>YY</a>

            <ul>
              <li><a href=''>YYY</a>
               
              </li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
By: TomH
Date: 2009-08-18
Time: 23:39

Re: Menu tree

There's a complete working hierarchical menu application at
http://tomhenry.us/tbs3/ at the top of the page.

* Unlimited levels
* No subqueries or recursion
* Automatic maintenance
* Simple or bulleted versions

Hope that helps,
TomH
By: sheepy
Date: 2009-08-19
Time: 04:44

Re: Menu tree

Hi. I almost always use the Modified Preorder Tree structure, which like TomH's example a single query does all the tricks provided that indent does the level trick instead of a real hierarchy.

I check TomH's example and noticed that it uses a text index (lineage). Has any benchmarking been done on tree update on large trees?  It's the pain of all tree that stores global hierarchy info, and I'm not confident on text index...

Anyway, here is an example of my modified pre-order tree that uses left, right, and tier in place of lineage.  I made it as an internal demo so I don't know how long it will last online.  It uses no ondata, no recursion, no plugin.

There are 2000-3000 tree items at this moment, and it locks down my add-on laden Firefox, so beware. (No problem with IE7)

http://zaris.demo.compelite.net/treedemo.php

Not only can a left-right tree shows complete tree in one go, it can also get all parents of a tree node in one query.
Or all children no matter how deep it is.
Or all direct child only.

All tree updates (insert/delete/move) needs one compound update query, followed by the insert or delete, transaction is not required to maintain data integrity.


PHP:
<?php
include_once('tbs_class.php');
$TBS = & new clsTinyButStrong ;
$TBS->LoadTemplate('template/admin.treedemo.html');
$dbc  = mysql_connect("localhost", "username", "password");
mysql_select_db("database",$dbc);
$TBS->MergeBlock('tree', $dbc, 'SELECT * FROM `z_category` order by `left`');
mysql_close($dbc);
$TBS->Show();
?>

HTML:
<html><body>
<div style='padding-left:[tree.tier]0px'><input type='checkbox' name='check[tree.id]'>[tree.title; block=div]</div>
</body></html>

MySQL (top 2 levels only, temp is unused):
CREATE TABLE IF NOT EXISTS `z_category` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `left` int(10) unsigned NOT NULL,
  `right` int(10) unsigned NOT NULL,
  `tier` smallint(5) unsigned NOT NULL,
  `temp` int(10) unsigned NOT NULL,
  `title` varchar(80) collate utf8_unicode_ci NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `tier` (`tier`),
  KEY `left_right` (`left`,`right`,`tier`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2640 ;

INSERT INTO `z_category` (`id`, `left`, `right`, `tier`, `temp`, `title`) VALUES
(1, 2, 29, 1, 3, 'Central African Republic'),
(2, 30, 57, 1, 3, 'Chad'),
(3, 58, 85, 1, 3, 'Comoros'),
(4, 86, 113, 1, 3, 'Congo, Republic of'),
(5, 114, 141, 1, 3, 'Congo, Democratic Republic of The'),
(6, 142, 169, 1, 3, 'Cote d''Ivoire'),
(7, 170, 197, 1, 3, 'Djibouti'),
(8, 198, 225, 1, 3, 'Egypt'),
(9, 226, 253, 1, 3, 'Equatorial Guinea'),
(10, 254, 281, 1, 3, 'Eritrea'),
(11, 282, 309, 1, 3, 'Ethiopia'),
(12, 310, 337, 1, 3, 'Gabon'),
(13, 338, 365, 1, 3, 'The Gambia'),
(14, 366, 393, 1, 3, 'Ghana'),
(15, 394, 421, 1, 3, 'Guinea'),
(16, 422, 449, 1, 3, 'Guinea-Bissau'),
(17, 450, 477, 1, 3, 'Ivory Coast (Cote d''Ivoire)'),
(18, 478, 505, 1, 3, 'Kenya'),
(19, 506, 533, 1, 3, 'Lesotho'),
(20, 534, 561, 1, 3, 'Liberia'),
(21, 562, 589, 1, 3, 'Libya'),
(22, 590, 617, 1, 3, 'Madagascar'),
(23, 618, 645, 1, 3, 'Malawi'),
(24, 646, 673, 1, 3, 'Mali'),
(25, 674, 701, 1, 3, 'Mauritania'),
(26, 702, 729, 1, 3, 'Mauritius'),
(27, 730, 757, 1, 3, 'Morocco'),
(28, 758, 785, 1, 3, 'Mozambique'),
(29, 786, 813, 1, 3, 'Namibia'),
(30, 814, 841, 1, 3, 'Niger'),
(31, 842, 869, 1, 3, 'Nigeria'),
(32, 870, 897, 1, 3, 'Rwanda'),
(33, 898, 925, 1, 3, 'Sao Tome and Principe'),
(34, 926, 953, 1, 3, 'Senegal'),
(35, 954, 981, 1, 3, 'Seychelles'),
(36, 982, 1009, 1, 3, 'Sierra Leone'),
(37, 1010, 1037, 1, 3, 'Somalia'),
(38, 1038, 1065, 1, 3, 'South Africa'),
(39, 1066, 1093, 1, 3, 'Sudan'),
(40, 1094, 1121, 1, 3, 'Swaziland'),
(41, 1122, 1149, 1, 3, 'Tanzania'),
(42, 1150, 1177, 1, 3, 'Togo'),
(43, 1178, 1205, 1, 3, 'Tunisia'),
(44, 1206, 1233, 1, 3, 'Uganda'),
(45, 1234, 1261, 1, 3, 'Zambia'),
(46, 1262, 1289, 1, 3, 'Zimbabwe'),
(47, 1292, 1319, 1, 3, 'Afghanistan'),
(48, 1320, 1347, 1, 3, 'Armenia'),
(49, 1348, 1375, 1, 3, 'Azerbaijan'),
(50, 1376, 1403, 1, 3, 'Bahrain'),
(51, 1404, 1431, 1, 3, 'Bangladesh'),
(52, 1432, 1459, 1, 3, 'Bhutan'),
(53, 1460, 1487, 1, 3, 'Brunei'),
(54, 1488, 1515, 1, 3, 'Burma (Myanmar)'),
(55, 1516, 1543, 1, 3, 'Cambodia'),
(56, 1544, 1571, 1, 3, 'China'),
(57, 1572, 1599, 1, 3, 'Georgia'),
(58, 1600, 1627, 1, 3, 'Hong Kong'),
(59, 1628, 1655, 1, 3, 'India'),
(60, 1656, 1683, 1, 3, 'Indonesia'),
(61, 1684, 1711, 1, 3, 'Iran'),
(62, 1712, 1739, 1, 3, 'Iraq'),
(63, 1740, 1767, 1, 3, 'Israel'),
(64, 1768, 1795, 1, 3, 'Japan'),
(65, 1796, 1823, 1, 3, 'Jordan'),
(66, 1824, 1851, 1, 3, 'Kazakhstan'),
(67, 1852, 1879, 1, 3, 'Korea, North'),
(68, 1880, 1907, 1, 3, 'Korea, South'),
(69, 1908, 1935, 1, 3, 'Kuwait'),
(70, 1936, 1963, 1, 3, 'Kyrgyzstan'),
(71, 1964, 1991, 1, 3, 'Laos'),
(72, 1992, 2019, 1, 3, 'Lebanon'),
(73, 2020, 2047, 1, 3, 'Malaysia'),
(74, 2048, 2075, 1, 3, 'Maldives'),
(75, 2076, 2103, 1, 3, 'Mongolia'),
(76, 2104, 2131, 1, 3, 'Myanmar'),
(77, 2132, 2159, 1, 3, 'Nepal'),
(78, 2160, 2187, 1, 3, 'Oman'),
(79, 2188, 2215, 1, 3, 'Pakistan'),
(80, 2216, 2243, 1, 3, 'Philippines'),
(81, 2244, 2271, 1, 3, 'Qatar'),
(82, 2272, 2299, 1, 3, 'Russia'),
(83, 2300, 2327, 1, 3, 'Saudi Arabia'),
(84, 2328, 2355, 1, 3, 'Singapore'),
(85, 2356, 2383, 1, 3, 'Sri Lanka'),
(86, 2384, 2411, 1, 3, 'Syria'),
(87, 2412, 2439, 1, 3, 'Taiwan'),
(88, 2440, 2467, 1, 3, 'Tajikistan'),
(89, 2468, 2495, 1, 3, 'Thailand'),
(90, 2496, 2523, 1, 3, 'Turkey'),
(91, 2524, 2551, 1, 3, 'Turkmenistan'),
(92, 2552, 2579, 1, 3, 'United Arab Emirates'),
(93, 2580, 2607, 1, 3, 'Uzbekistan'),
(94, 2608, 2635, 1, 3, 'Vietnam'),
(95, 2636, 2663, 1, 3, 'Yemen'),
(96, 2666, 2693, 1, 3, 'Albania'),
(97, 2694, 2721, 1, 3, 'Andorra'),
(98, 2722, 2749, 1, 3, 'Austria'),
(99, 2750, 2777, 1, 3, 'Belarus'),
(100, 2778, 2805, 1, 3, 'Belgium'),
(101, 2806, 2833, 1, 3, 'Bosnia and Herzegovina'),
(102, 2834, 2861, 1, 3, 'Bulgaria'),
(103, 2862, 2889, 1, 3, 'Croatia'),
(104, 2890, 2917, 1, 3, 'Cyprus'),
(105, 2918, 2945, 1, 3, 'Czech Republic'),
(106, 2946, 2973, 1, 3, 'Denmark'),
(107, 2974, 3001, 1, 3, 'Estonia'),
(108, 3002, 3029, 1, 3, 'Finland'),
(109, 3030, 3057, 1, 3, 'France'),
(110, 3058, 3085, 1, 3, 'Germany'),
(111, 3086, 3113, 1, 3, 'Greece'),
(112, 3114, 3141, 1, 3, 'Hungary'),
(113, 3142, 3169, 1, 3, 'Iceland'),
(114, 3170, 3197, 1, 3, 'Ireland'),
(115, 3198, 3225, 1, 3, 'Italy'),
(116, 3226, 3253, 1, 3, 'Latvia'),
(117, 3254, 3281, 1, 3, 'Liechtenstein'),
(118, 3282, 3309, 1, 3, 'Lithuania'),
(119, 3310, 3337, 1, 3, 'Luxembourg'),
(120, 3338, 3365, 1, 3, 'Macedonia'),
(121, 3366, 3393, 1, 3, 'Malta'),
(122, 3394, 3421, 1, 3, 'Moldova'),
(123, 3422, 3449, 1, 3, 'Monaco'),
(124, 3450, 3477, 1, 3, 'Netherlands'),
(125, 3478, 3505, 1, 3, 'Norway'),
(126, 3506, 3533, 1, 3, 'Poland'),
(127, 3534, 3561, 1, 3, 'Portugal'),
(128, 3562, 3589, 1, 3, 'Romania'),
(129, 3590, 3617, 1, 3, 'Russia'),
(130, 3618, 3645, 1, 3, 'San Marino'),
(131, 3646, 3673, 1, 3, 'Serbia and Montenegro'),
(132, 3674, 3701, 1, 3, 'Slovakia (Slovak Republic)'),
(133, 3702, 3729, 1, 3, 'Slovenia'),
(134, 3730, 3757, 1, 3, 'Spain'),
(135, 3758, 3785, 1, 3, 'Sweden'),
(136, 3786, 3813, 1, 3, 'Switzerland'),
(137, 3814, 3841, 1, 3, 'Turkey'),
(138, 3842, 3869, 1, 3, 'Ukraine'),
(139, 3870, 3897, 1, 3, 'United Kingdom'),
(140, 3898, 3925, 1, 3, 'Vatican City'),
(141, 3928, 3955, 1, 3, 'Australia'),
(142, 3956, 3983, 1, 3, 'Fiji'),
(143, 3984, 4011, 1, 3, 'Kiribati'),
(144, 4012, 4039, 1, 3, 'Marshall Islands'),
(145, 4040, 4067, 1, 3, 'Micronesia'),
(146, 4068, 4095, 1, 3, 'Nauru'),
(147, 4096, 4123, 1, 3, 'New Zealand'),
(148, 4124, 4151, 1, 3, 'Palau'),
(149, 4152, 4179, 1, 3, 'Papua New Guinea'),
(150, 4180, 4207, 1, 3, 'Samoa'),
(151, 4208, 4233, 1, 3, 'Solomon Islands'),
(152, 4236, 4259, 1, 3, 'Tonga'),
(153, 4262, 4285, 1, 3, 'Tuvalu'),
(154, 4288, 4311, 1, 3, 'Vanuatu'),
(155, 4316, 4339, 1, 3, 'Antigua and Barbuda'),
(156, 4342, 4365, 1, 3, 'Barbados'),
(157, 4368, 4391, 1, 3, 'Belize'),
(158, 4394, 4417, 1, 3, 'Canada'),
(159, 4420, 4443, 1, 3, 'Costa Rica'),
(160, 4446, 4469, 1, 3, 'Cuba'),
(161, 4472, 4495, 1, 3, 'Dominica'),
(162, 4498, 4521, 1, 3, 'Dominican Republic'),
(163, 4524, 4547, 1, 3, 'El Salvador'),
(164, 4550, 4573, 1, 3, 'Greenland (Kalaallit Nunaat)'),
(165, 4576, 4599, 1, 3, 'Grenada'),
(166, 4602, 4625, 1, 3, 'Guatemala'),
(167, 4628, 4651, 1, 3, 'Haiti'),
(168, 4654, 4677, 1, 3, 'Honduras'),
(169, 4680, 4703, 1, 3, 'Jamaica'),
(170, 4706, 4729, 1, 3, 'Mexico'),
(171, 4732, 4755, 1, 3, 'Nicaragua'),
(172, 4758, 4781, 1, 3, 'Panama'),
(173, 4784, 4807, 1, 3, 'Saint Kitts and Nevis'),
(174, 4810, 4833, 1, 3, 'Saint Lucia'),
(175, 4836, 4859, 1, 3, 'Saint Vincent and the Grenadines'),
(176, 4862, 4885, 1, 3, 'The Bahamas'),
(177, 4888, 4911, 1, 3, 'Trinidad and Tobago'),
(178, 4914, 4937, 1, 3, 'United States of America'),
(179, 4942, 4965, 1, 3, 'Argentina'),
(180, 4968, 4991, 1, 3, 'Bolivia'),
(181, 4994, 5017, 1, 3, 'Brazil'),
(182, 5020, 5043, 1, 3, 'Chile'),
(183, 5046, 5069, 1, 3, 'Colombia'),
(184, 5072, 5095, 1, 3, 'Ecuador'),
(185, 5098, 5121, 1, 3, 'French Guiana'),
(186, 5124, 5147, 1, 3, 'Guyana'),
(187, 5150, 5173, 1, 3, 'Paraguay'),
(188, 5176, 5199, 1, 3, 'Peru'),
(189, 5202, 5225, 1, 3, 'Suriname'),
(190, 5228, 5251, 1, 3, 'Uruguay'),
(191, 5254, 5277, 1, 3, 'Venezuela'),
(192, 1, 1290, 0, 46, 'Africa'),
(193, 1291, 2664, 0, 49, 'Asia'),
(194, 2665, 3926, 0, 45, 'Europe'),
(195, 3927, 4312, 0, 14, 'Australia/Pacific'),
(196, 4315, 4938, 0, 24, 'North America'),
(197, 4941, 5278, 0, 13, 'South America')
By: TomH
Date: 2009-08-19
Time: 13:16

Re: Menu tree

Hi sheepy,

Thanks for showing your stuff, you always make good contributions to TBS forum!

My tree was only ever originally intended for doing website navigation but maybe I should expand it for more strenuous uses.

I've never tested large numbers of entries - but now you make me wonder about it - of course it would need mysql indexing on the main field so that should be the speed limitation. What do you think? Of course if the volatility of the changes is low then a cached page might suffice.

I'd like to play with your example - do you mind?

Would you share the code for maintaining the tree?

Thanks,
TomH
By: Sheepy
Date: 2009-08-24
Time: 10:54

Re: Menu tree

Sure~ Let me try to find a more complete code and put it somewhere. But it may take a while.  I haven't touched php for a while, actually.