RE: [PEAR] re: TreeMenu and Recursive algorithms
| From: | Joseph Blythe | Date: | Fri, 11 Apr 2003 06:15:14 +0000 |
| Subject: | RE: [PEAR] re: TreeMenu and Recursive algorithms | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143454@lists.php.net to get a copy of this message | ||
It seems to me that there is some sort of bug in TreeMenu.php when using the
createFromStructure($params) function and passing the $params['nodeOptions']
for use with HTML_TreeNode( $data , $events ) so I am guessing there is
something up with the splitting of the $params[] array into the $data[],
$events[] arrays I just can't seem to figure it out the options thing has me
really confused now!
Even if this would work that would fix adding the links to each node and the
folder icons, but I still would need a way to pass each category id from the
original tree options to the nodeOptions.
Slight change still same result :)
snip--
/ Tree
$icon = "folder.gif";
$expanded_icon = "folder-expanded.gif";
$options = array('table' => 'categories',
'order' => 'category',
'columnNameMaps' => array('parentId' => 'predcessor',
'name' => 'category'));
$tree = Tree::setupMemory('DBsimple', $dsn, $options);
$tree->setup();
$node_options = array('text' => '',
'link' => "editCategory.php?id=",
'icon' => $icon,
'expandedIcon' => $expanded_icon);
$_treeMenu = HTML_TreeMenu::createFromStructure(array('structure' => $tree,
'type' => 'kriesing',
'nodeOptions' = $node_options));
$treeMenu = new HTML_TreeMenu_DHTML($_treeMenu, array('images' =>
'images/tree/',
'defaultClass' => 'text'));
--snip
I suspect I may just be doing it all wrong, but that wouldnt be the first
time :)
Hope this makes some sense, well nearly time to knock off so I will have to
leave it until Monday, have a great weekend all :)
Regards,
Joseph Blythe
-----Original Message-----
From: Joseph Blythe [mailto:joseph@optcom.net.au]
Sent: Friday, 11 April 2003 10:18 AM
To: 'Wolfram Kriesing'; jeroen@terena.nl
Cc: pear-general@lists.php.net
Subject: RE: [PEAR] re: TreeMenu and Recursive algorithms
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
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php