function drupal_get_destination

Prepares a 'destination' URL query parameter for use 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.

Return value

An associative array containing the key:

  • destination: The path provided via the destination query string or, if not available, the current path.

See also

current_path()

drupal_goto()

Related topics

42 calls to drupal_get_destination()
comment_admin_overview in drupal/core/modules/comment/comment.admin.inc
Form constructor for the comment overview administration form.
common_test_destination in drupal/core/modules/system/tests/modules/common_test/common_test.module
Prints a destination query parameter.
ContextualLinks::render in drupal/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
Render the contextual fields.
contextual_pre_render_links in drupal/core/modules/contextual/contextual.module
Pre-render callback: Builds a renderable array for contextual links.
FieldOverview::submit in drupal/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php
Overrides Drupal\field_ui\OverviewBase::submit().

... See full list

1 string reference to 'drupal_get_destination'
views_ajax in drupal/core/modules/views/includes/ajax.inc
Menu callback to load a view via AJAX.

File

drupal/core/includes/common.inc, line 532
Common functions that many Drupal modules will need to reference.

Code

function drupal_get_destination() {
  $destination =& drupal_static(__FUNCTION__);
  if (isset($destination)) {
    return $destination;
  }
  if (isset($_GET['destination'])) {
    $destination = array(
      'destination' => $_GET['destination'],
    );
  }
  else {
    $path = current_path();
    $query = drupal_http_build_query(drupal_get_query_parameters());
    if ($query != '') {
      $path .= '?' . $query;
    }
    $destination = array(
      'destination' => $path,
    );
  }
  return $destination;
}