Tuesday, July 26, 2011

Alter Menu Title in drupal 6 using hooks

we can alter Menu Title in drupal 6 using hooks using phptemplate_menu_item_link($item) function in template.php file

for Eg:


function phptemplate_menu_item_link($item) {

    if( strpos($item['title'], 'Administer') === 0) {

         $item['title']='Administer Kapil';
           return l($item['title'], $item['link_path'], !empty($item['description']) ? array('title' => $item['description']) : array(), NULL, NULL, FALSE, FALSE);
    }
  
     return l($item['title'], $item['link_path'], !empty($item['description']) ? array('title' => $item['description']) : array());
}


This function will change "Administer" menu title in Navigation menu to 'Administer Kapil'. 

and we can also use html tags in Menu title if we set 7th parameter in return statement to TRUE...

No comments:

Post a Comment