Skip to main content

Modifying the Drupal local tasks to include the destination

An article from ComputerMinds - Building with Drupal in the UK since 2005
17th Jun 2007

Mike Dixon

Senior Mind
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?

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'){
    $item['query']='destination='.$_GET['destination'];
    }
  }
  return theme_menu_item_link($item,$link_item);
}

Hi, thanks for reading

ComputerMinds are the UK’s Drupal specialists with offices in Bristol and Coventry. We offer a range of Drupal services including Consultancy, Development, Training and Support. Whatever your Drupal problem, we can help.