Home » HTML » HTML_Menu » Bug #3029
Notice in _buildUrlMap when url is missing
Details
| Submitted | 2004-12-26 16:38 UTC |
|---|---|
| From | strauchdieb at gmx dot de |
| Assigned | avb |
| Status | Closed |
| Package | HTML_Menu |
| PHP Version | 4.3.6 |
| OS | Mac 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."