Archive for May, 2009

Add absolute link menu item to user menu in Drupal

First of all, user menu (local tasks) in Drupal cannot be edited via admin. To add items to the menu you need to create new module and implement hook_menu() in it.
The following example shows how to do it in Drupal 6:

function yourmodule_menu() {
  $items['http://some.url'] = array(
    'tab_root'	=> 'user',
    'tab_parent'	=> 'user',
    'title' => 'External URL',
    'page callback' => 'user_page',
    'access callback' => 'user_is_anonymous',
    'type' => MENU_LOCAL_TASK,
    'weight'	=> 5
  );
 
  return $items;
}

Change ‘access callback’ to whatever function (or constant) you want, but don’t forget to set ‘page callback’. It is being checked when building menu structure even if we don’t have any page callback actually.

Thursday, May 21st, 2009