For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > May 2004 > Html_Menu - Assigning urls to nodes









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Html_Menu - Assigning urls to nodes
Pete

2004-05-26, 5:37 am

Hi,

I am trying to use the Html_Menu class' example script:

How can I change this line:

foreach ($data as $id => $node) {
$data[$id]['url'] = $_SERVER['PHP_SELFT']."?nodeID=".$node['id'];
}

so that i get actual links to different pages? When I change $_SERVER['PHP_SERVER'] to $data[$id]['url'] the links refer to different pages but the menu doesn't work anymore. Really, I am giving up. Tried all day yesterday.The documentation doesn't help at all.

....
$params = array(
'id' => 'id',
'parent_id' => 'rootid',
'left_id' => 'l',
'right_id' => 'r',
'order_num' => 'norder',
'level' => 'level',
'id_trans' => 'id_trans',
'url' => 'url',
'name' => 'name',
);

$nestedSet =& DB_NestedSet::factory('DB', $dsn, $params);
// we want the nodes to be displayed ordered by name, so we add the secondarySort attribute
$nestedSet->setAttr(array(
'node_table' => 'nested_set',
'lock_table' => 'nested_set_locks',
'secondarySort' => 'name',
)
);
// get data (important to fetch it as an array, using the true flag)
$data = $nestedSet->getAllNodes(true);

// }}}
// {{{ manipulate data

// add links to each item
foreach ($data as $id => $node) {
$data[$id]['url'] = $_SERVER['php_self']."?nodeID=".$node['id'];
}

....
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com