I need to add the URL 'user/7/orders' to a particular menu. As this requires PHP for the UID (7), how do I write a script to add an item to a particular menu?
+1
A:
You can use the menu hook for this.
Assuming you have your own custom module on your site, this should work -
function custom_menu() {
$items = array();
$items['user/7/orders'] = array(
'title' => 'My Orders',
'page callback' => 'custom_order_callback',
'access callback' => user_access('access content'), // You can change this
'type' => MENU_LOCAL_TASK
}
return $items;
}
If you want the Orders tab to show up for all users, you can use $items['user/%/orders']
above and get the page arguments to prepare your data.
For the menu type, you can use MENU_CALLBACK, MENU_LOCAL_TASK or MENU_DEFAULT_LOCAL_TASK. Check here to see how they differ.
Amar Ravikumar
2010-05-04 07:32:48
Thanks for your answer, I've gone the easy way though (with the answer below) but I've learnt something from your answer at least !
Dallas Clark
2010-05-05 00:39:10
A:
Not sure if I understand your question correctly, but if you need to add that menu work for each user and their orders, you could use the Me module (http://drupal.org/project/me) and then create a menu item linking to "user/me/orders".
JarodMS
2010-05-04 14:45:44