Hi,

I recently modified my menu.inc function theme_menu_item_link($item, $link_item) from:

return l($item['title'], $link_item['path'], array_key_exists('description', $item) ? array('title' => $item['description']) : array());

to:
return l($item['title'], $link_item['path'], $item['attributes']);

I did this so that I could setup a menu array w/ the following element:
'attributes' => array('onMouseOver' => 'showThumb()',
'onMouseOut' => 'hideThumb()'),

Can anyone tell me why the menu.inc would not pass the attributes along to the link function...I don't understand the point of 'array_key_exists('description', $item) ? array('title' => $item['description']) : array()'

Comments

bhagman’s picture

Well, as near as I can tell, it seems that there is no place to enter additional attributes for menu items in the included menu.module (plus, there is no "attributes" field in the database for menu items). That would be a nifty feature though. A little frivolous, but nontheless, nifty. ;)

I think the idea is that the l() function is being reused, and since there are no attributes as such for the menu items, then the best that can be done is to put the description into the "title" attribute. Make sense?

array_key_exists('description', $item) ? array('title' => $item['description']) : array()

This just puts the description (if it exists) into the "title" attribute in the link.
eg. <a href="somelink" title="my description">