I have the following in my theme:
$items['user/%user/sms-services'] = array(
'title' => t('SMS Services'),
'page callback' => 'sms_user_page',
'page arguments' => array(1),
'access callback' => 'user_is_logged_in',
'type' => MENU_LOCAL_TASK,
);
It works great in that it:
- Creates a url /user/USER_ID/sms-services
- Creates a tab on the /user page
However, I want to get rid of the USER ID part. I.e. The link must work as:
/user/sms-services
And /user/USER_ID/sms-services must redirect to /user/sms-services
And /user/USER_ID must redirect to /user
Is there an easy way to do this?
UPDATE
I used the "me aliases" module to accomplish much of this, but it's still not a very elegant solution, because now i'm stuck with TWO urls working:
/user/me/some-action
AND
/users/393/some-action
When all I really wanted was:
/user/some-action
Anyone got any ideas?
Maybe you can do sometinhg like this instead. Check if the user entering user/sms-services is logedin by using user_is_logged_in, if true use the global $user for further stuff. Maybe something like this
And maybe make a drupal_goto() from the old ones (menu items with the user wildcard to the new ones)
Very importat:
Do not use t() function in your menu item. By defualt drupal will pass the title string into the function t(). You can change that behavior by setting a new 'title callback' in your menu item array
See hook_menu from drupal.org