RE: [PEAR] re: TreeMenu and Recursive algorithms
| From: | Joseph Blythe | Date: | Fri, 11 Apr 2003 00:47:58 +0000 |
| Subject: | RE: [PEAR] re: TreeMenu and Recursive algorithms | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4792@lists.php.net to get a copy of this message | ||
Thankyou guys :)
I basically have it working but still having problems with the folder icons
and am getting a reapeating error message: "Notice: Undefined index: text in
/usr/local/Zend/lib/php/HTML/TreeMenu.php on line 165", also how would I
specify a link for each node which needs to pass the categorories id via the
url ?
The code so far: I left Wolfram's comment in as it makes me laugh )
// Tree
$icon = "folder.gif";
$expanded_icon = "folder-expanded.gif";
$options = array('table' => 'categories',
'order' => 'id',
'columnNameMaps' => array(
'parentId' => 'predcessor',
'name' => 'category'));
$tree = Tree::setupMemory('DBsimple', $dsn, $options);
$tree->setup();
//$tree->varDump();
$options = array('images' => 'images/tree/', 'defaultClass' =>
'text',
'text' => 'category');
$_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);
Thankyou again for the help is appreciated ,
Regards,
Joseph Blythe
-----Original Message-----
From: Wolfram Kriesing [mailto:wolfram@visionp.de]
Sent: Thursday, 10 April 2003 6:42 PM
To: Jeroen Houben
Cc: Joseph Blythe; pear-general@lists.php.net
Subject: Re: [PEAR] re: TreeMenu and Recursive algorithms
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
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php