Hi,

i try to upgrade this function from drupal 5 to drupal 6, i read this link (http://drupal.org/node/103114) but it's don't work. Somebody can help me ?

my V5 function :

function dimar_address_menu($may_cache) {
  global $user;
  $uid = $user->uid;
  $items = array();

  if ($may_cache) {
  }
  else {
    if (arg(0) == 'user') {
      if (user_access('administer users')) {
        $uid = arg(1);
      }
      if ($uid) {
        $items[] = array(
          'path' => "user/$uid/dimar_address",
          'title' => t('Address Book'),
          'callback' => 'dimar_address_page',
          'access' => TRUE,
          'type' => MENU_LOCAL_TASK,
          'weight' => 1,
        );
      }
    }
  }

  return $items;
}
php

on V6 :


function dimar_address_menu() {

  $items['user/%user_uid/dimar_address'] = array(
    'title' => 'Address Book',
    'page callback' => 'dimar_address_page',
	'access arguments' => array('administer users'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
  );
  return $items;
}

php

Thanks in advance !

Comments

nevets’s picture

What does not work mean? Do you get a page not found or something else?

moksa’s picture

There is no "Address Book" tabmenu on 'My account' page. With the first function on my drupal 5 it's work.

nevets’s picture

Looking at tracker.module I think you want


  $items['user/%user/dimar_address'] = array(
    'title' => 'Address Book',
    'page callback' => 'dimar_address_page',
    'page arguments' => array(1),
    'access arguments' => array('administer users'),
    'type' => MENU_LOCAL_TASK,
    'weight' => 1,
  );

Note your callback will be pased an user object as an argument (look at tracker_page in tracker.pages.inc). Also, if the a tab still does not show visit the menu admin page (this should cause the menus to be rebuilt).

moksa’s picture

Thanks a lot, it's ok.

parkej60’s picture

Hello,

I ran across this post and thought maybe someone could help me getting this to work. This is my code.

function onthisdate_menu(){
$items['user/%user/onthisdate'] = array(
'title' => 'Address Book',
'page callback' => 'onthisdate_contact_info',
'access arguments' => array('administer users'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);

}
function onthisdate_contact_info() {
echo "Test";
}

The tab will not even show up on the page for me, this is supposed to show up next to the View - Edit - Track tabs correct?

parkej60’s picture

Nevermind I forgot to put the return in the function.