Description in menu
munkiepus - December 18, 2008 - 07:52
| Project: | Local Menu |
| Version: | 6.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Is there any way to add the description of a menu item below the item itself?
I notice that the description is stored in the attributes column for the menu which would make it more difficult to extract, maybe one of the drupal menu functions has this ability already.
This could then display a menu similar to the admin/content page where the description is shown below the menu item.
Any ideas? I could probably work a patch myself but could do with some input first.
Cheers

#1
It needs work but I put this
<?php
/*
* @file
*
* Display the materials and engineering data
*
* In a way that it can then filter
* and sort the data as requested.
* views fell short of doing this.
*/
/**
* Implementation of hook_block().
*/
function menudesc_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Menus With Descriptions');
$blocks[0]['cache'] = BLOCK_NO_CACHE;
return $blocks;
case 'view':
$items = array();
//menu_links and this uses menu-mainmenu as the Welcome menu
//
$result = db_query("SELECT *
FROM {menu_links}
WHERE menu_name LIKE 'menu-mainmenu' ORDER BY weight
LIMIT 20");
while ($data = db_fetch_object($result)) {
$menudesc = substr(''.$data->options.'', 46);
$menudesc = substr(''.$menudesc.'', 0, -4);
$items[] = l("<div class=topmenuitem>$data->link_title</div><p>$menudesc</p>", $data->link_path, array('html'=>'TRUE'));
}
$block['subject'] = t('Welcome');
// We theme our array of links as an unordered list.
//$block['content'] = $menudesc;
$block['content'] = theme('item_list', $items);
}
return $block;
}
Into the module folder as a folder called menudesc and a file called menudesc.module
Then
make this in that folder as a file called menudesc.info
And you should now have a block you can turn on to do this once you turn on the menu.
<?php; Id$
name = Menu w Description
core = 6.x
description = Create a menu w their descriptions
version = "$Name$"
But there are some hardcoded items.
1. line 26 menu-mainmenu this menu names needs to match the module you want.
2. line 35 title could be driven from #1 and the query.
#2
Thanks for that work,
Was looking to add this into the local menu module so that i could use the Starting depth and Rendered depth. Exactly the same way ad the localmenu module does.
As far as i can see there are only 2 selects in the localmenu.module, one which takes {menu_custom} which is no use.
One which uses and one which uses "SELECT mlid FROM {menu_links}". I was wondering if the menu description could be added into the could be added to the $items[] array in there using $data->options from that {menu_links} select.
I'm not really sure where the main module gets the title and router_path link_title from the menu_links table, any ideas?
Thanks
#3
this would definitely be a great feature !
#4
I would appreciate this feature also.