PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_Menu » Bug #3029

Notice in _buildUrlMap when url is missing

Details

Submitted2004-12-26 16:38 UTC
Fromstrauchdieb at gmx dot de
Assignedavb
StatusClosed
PackageHTML_Menu
PHP Version4.3.6
OSMac OS X
Roadmaps(Not assigned)

Comments

[2004-12-26 16:38 UTC] strauchdieb at gmx dot de

Description:
------------
When using an array where some menu elements don't have
a 'url' index, I get the following error notice:

Undefined index: url in HTML/Menu.php on line 478

My proposition would be to either chnage the code in
this line or explicitly state in the documentation that
the url index is needed for each menu element.

I'm using the current version (2.1.1) of HTML_Menu

[2004-12-26 16:46 UTC] strauchdieb at gmx dot de

A possible fix in the code would look like this.
Don't know if it breaks anything.

function _buildUrlMap($menu, $path)
{
foreach ($menu as $nodeId => $node) {
if(isset($node['url']))
{
$url = $this->_urlPrefix .
((empty($this->_urlPrefix) || '/' != $node['url']{0})?
$node['url']: substr($node['url'], 1));
$this->_urlMap[$url] = $path;

if ($url == $this->_currentUrl) {
return true;
}
}

if (isset($node['sub']) &&
$this->_buildUrlMap($node['sub'],
array_merge($path, array($nodeId)))) {
return true;
}
}
return false;
}

[2004-12-28 21:32 UTC] strauchdieb at gmx dot de

My proposition for the documentation would be
"Each entry has at least the 'url' and 'title' elements and may also have a 'sub' element containing the children of this entry."