Re: re: TreeMenu and Recursive algorithms

From: Date: Thu, 10 Apr 2003 09:11:54 +0000
Subject: Re: re: TreeMenu and Recursive algorithms
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4766@lists.php.net to get a copy of this message
Jeroen Houben wrote:
Joseph Blythe wrote:
I have a mySQL database table: id tinyint(4) unsigned NOT NULL auto_increment, category varchar(50) NOT NULL default '', predcessor tinyint(4) unsigned default NULL, PRIMARY KEY (id), UNIQUE KEY category (category)
Hi Joseph, You should have a look at PEAR::Tree (http://pear.php.net/package-info.php?pacid=104). It does all the recursive stuff for you and if I'm not mistaking PEAR::TreeMenu can even take a PEAR::Tree instance and generate the menu from that tree.
Yes, exactly. you can see http://cvs.php.net/co.php/pear/Tree/docs/Memory_DBsimple.php?r=1.2 for an example how to read the tree it should work somehow like this: $options = array( 'table' => 'myTree',
                    'order' =>  'id',
                    'columnNameMaps'=>array(
                       'parentId'      =>  'predcessor'
                       'name'          =>  'category')
                );
$tree = Tree::setupMemory('DBsimple',// use the simple DB schema
                          'mysql://root@localhost/test',  // the DSN
                          $options);
$tree->setup(); // and now import it into HTML_TreeMenu $icon = 'folder.gif'; $options = array('images'=>'/path/to/images'); $_treeMenu = HTML_TreeMenu::createFromStructure( array( 'structure'=>$tree, // this is really ugly, Richy // i could kick ur ass for that :-) // but it works 'type'=>'kriesing' ) ); $treeMenu = new HTML_TreeMenu_DHTML($_treeMenu,$options); i have not tried it, but it should work .... so you wont need recursion, etc. have fun -- Wolfram ... opensource @ vision:produktion ... http://opensource.visionp.de ... translating template engine .... http://sf.net/projects/simpletpl ... authentication system .... http://sf.net/projects/auth

« previous php.pear.general (#4766) next »