Closed (fixed)
Project:
DHTML Menu
Version:
5.x-1.6
Component:
User Interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Jan 2009 at 03:59 UTC
Updated:
7 Feb 2009 at 02:56 UTC
Greetings, thankyou I am enjoying your great DHTML menu module!
I am learning to theme drupal and I am a non-programmer.
I have found this code snippet from http://drupal.org/node/227607
function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
$item = menu_get_item($mid); // get current menu item
// decide whether to add the active class to this menu item
if ((drupal_get_normal_path($item['path']) == $_GET['q']) // if menu item path...
|| (drupal_is_front_page() && $item['path'] == '<front>')) { // or front page...
$active_class = ' active'; // set active class
} else { // otherwise...
$active_class = ''; // do nothing
}
$attribs = isset($item['description']) ?
array('title' => $item['description']) : array();
$replace = array(' ', '&');
$attribs['id'] = 'menu-'. str_replace($replace, '-', strtolower($item['title']));
return
'<li class="'. ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) . (menu_in_active_trail($mid) ? ' parent' : '') . $active_class .'" id="'. $attribs['id'] . '">' . menu_item_link($mid) . $children ."</li>\n";
}
After putting it into my theme's template.php it create a unique css ID for all the menu items from the core menu module which is perfect for any themer's requirements.
I am curious why this does not work for this module and whether you would consider implementing this as I think its a big disadvantage to drupal themers.
Cheers again.
Comments
Comment #1
imp7 commentedI just learnt that themes can certain module functions, I just wish I could write functions like this myself!
This code works fine for others who are looking to do get some themes cranking.. :)
Comment #2
imp7 commentedComment #3
imp7 commentedI just jumped the gun, when the overriding of dhtml_menu_item I am guessing that the javascript doesn't know what to select anymore.
Any help on giving each menu item in the list an id relative to their menu name / position / state would be much appreciated.
Comment #4
ckidowsubscribing
Comment #5
imp7 commentedWell over the time to try and find a good method I have also upgraded to 6.x and there is a sweet as module called
http://drupal.org/project/menu_attributes
You can set a bunch of custom attributes for all menu items individually so its just a matter of setting up some simple css.
Comment #6
imp7 commented