0

I am using hook_theme_registry_alter() in my custom module for overriding the theme function. I have done something like this in my module file aml.module

function aml_theme_registry_alter (&$theme_registry) {
  $theme_registry['aml']['function'] = 'theme_menu_item_link';
  dsm($theme_registry);

}

function theme_menu_item_link () {
  drupal_set_message("hello");
}

I don't know how and where to implement this function theme_menu_item_link

0

I think you are trying to alter a $theme_registry['aml']['function'] which doesn't exist.

Try have a look through the $theme_registry array, and find what you want to override, put this in where you currently have "['aml']". I am guessing you want "['menu_item_link']", but you will have to check.

Then change theme_menu_item_link to aml_menu_item_link.

  • Hey I have done as you have mentioned. Overridden ['menu_link']['function'] = 'theme_menu_link' and changed the function name from theme_menu_link to aml_menu_link() and dispalyed some simple text but still not getting any output – Somya Gupta Mar 28 '12 at 10:15
  • Have you cleared cache? You must clear cache each time with this function. Also is menu_link in the $them_registry array? Also to confirm this code will need to be in a custom module named aml not in the template.php – WestieUK Mar 28 '12 at 11:08
  • yes I have created a custom module named aml and have put this code in .module file. Tell me if there is any other option to override theme function in a module file instead altering theme registry as I want to provide page specific visibility to menu items through my module – Somya Gupta Mar 28 '12 at 11:19
  • I dont think there is a another hook which would do the same thing as it would need to have the full $theme_registry array with additional properties added by _theme_process_registry(). have you tried looking at altering the menu's themselves? You could try hook_menu_link_alter with some if statements to unset menu items? – WestieUK Mar 28 '12 at 11:42
  • yes I have used hook_form_form_id_alter in my module for menu edit item form. With the help of this hook I implemented the user interface for my module. Just like in block module there are visibility settings option by which the user can choose the path on which the menu link has to be active. – Somya Gupta Mar 28 '12 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.