function drupal_get_destination

7.x common.inc drupal_get_destination()
6.x common.inc drupal_get_destination()

Prepare a destination query string for use in combination with drupal_goto().

Used to direct the user back to the referring page after completing a form. By default the current URL is returned. If a destination exists in the previous request, that destination is returned. As such, a destination can persist across multiple pages.

See also

drupal_goto()

Related topics

16 calls to drupal_get_destination()
comment_admin_overview in drupal-6.x/modules/comment/comment.admin.inc
Form builder; Builds the comment overview form for the admin.
hook_translated_menu_link_alter in documentation-6.x/developer/hooks/core.php
Alter a menu link after it's translated, but before it's rendered.
node_admin_nodes in drupal-6.x/modules/node/node.admin.inc
Form builder: Builds the node administration overview.
node_form_delete_submit in drupal-6.x/modules/node/node.pages.inc
Button sumit function: handle the 'Delete' button on the node form.
openid_authentication in drupal-6.x/modules/openid/openid.module
Authenticate a user or attempt registration.

... See full list

File

drupal-6.x/includes/common.inc, line 261
Common functions that many Drupal modules will need to reference.

Code

function drupal_get_destination() {
  if (isset($_REQUEST['destination'])) {
    return 'destination=' . urlencode($_REQUEST['destination']);
  }
  else {
    // Use $_GET here to retrieve the original path in source form.
    $path = isset($_GET['q']) ? $_GET['q'] : '';
    $query = drupal_query_string_encode($_GET, array('q'));
    if ($query != '') {
      $path .= '?' . $query;
    }
    return 'destination=' . urlencode($path);
  }
}