Author image
Senior Mind

Modifying the Drupal local tasks to include the destination

There is nothing worse than having your browsing flow interrupted by a login screen that does not return you to your origional destination. Drupal manages to get around this problem by allowing you to append a "destination=XXX" query string parameter to the 'user' login URL.

This is excellent and works well, except what happens if the user clicks the register tab while on the login screen - the destination query string is lost and the user has to resort to the back button.

This little snippet attempts to solve this problem - stick it into your template.php file, it very simply just adds the destination query string to each of the local tasks.

It is completley untested so use at your own risk!!

function phptemplate_menu_item_link($item, $link_item){
  if (isset($_GET['destination'])){
    if ($link_item['path']=='user/register' || $link_item['path']=='user' || $link_item['path']=='user/password'){
  return theme_menu_item_link($item,$link_item);