Hello everybody !
First of all, i want to say hello to the whole Drupal community. I love to see how much energy you guys put in developing, improving and supporting the system and its users... Keep up the good work !!!
I am relatively new to Drupal. I have been studying it for a while now and i just love the structure and philosophy behind it. Normally i try to find answers to my questions by googling it and looking through the forums... however this time, i decided to use the forum myself...
My question is the following: I have implemented the following function override in my template.php: myThemeName_preprocess_menu_item(&$vars). I also make use of the module menu_block_split.
However, the argument $vars['extra_class'], which i need to determine the first and last item of a menu list, does not get through. When I started debugging the code i noticed that it is well passed through theme('menu_item', $link, 0, '', $in_active_trail, $extra_class);, but when the theme() function start to convert the arguments to a $variables array, it uses the list of argument names in $hooks['menu_item']['arguments']. When i examined this list, i saw that is only has 3 arguments and not 5, like in theme('menu_item', $link, 0, '', $in_active_trail, $extra_class).
Can anybody explain me where and how this list is built, and why it only has three arguments instead of five, in the specific case of menu_item ? Or, more generally, is there any post/document/tutorial on how Drupal 6 deals with variables, declarations, how variables are passed on to functions etc... I am used to a more OO type of programming, but i guess the way drupal deals with variables is a little different.
I am sure that understanding the exact working of how variables are passed from function to function will greatly help my understanding of the Drupal system.
Thank you very much for helping me clarify this !!!
Best regards,
Martin (dancinbits)
Comments
menu_item: different argument lists ???
Hello,
Can somebody please explain me why the hook menu_item has 3 arguments declared, but when the hook is called 5 are passed along ?
I understand that the argument list for the theme hook 'menu_item' is declared in common.inc, as follows :
'menu_item' => array('arguments' => array('link' => NULL, 'has_children' => NULL, 'menu' => ''),)
However, in the file menu.inc, the theme_menu_item function is declared as follows:
function theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL)
I noticed the difference because the extra_class 'first' and 'last' is not passed along and does not get into my html properly...
Any clarification would be very welcome.
All the best,
Martin