1 common.inc backdrop_get_destination()

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


Related topics


core/includes/common.inc, line 654
Common functions that many Backdrop modules will need to reference.


function backdrop_get_destination() {
  $destination = &backdrop_static(__FUNCTION__);

  if (isset($destination)) {
    return $destination;

  if (isset($_GET['destination'])) {
    $destination = array('destination' => $_GET['destination']);
  else {
    $path = $_GET['q'];
    $query = backdrop_http_build_query(backdrop_get_query_parameters());
    if ($query != '') {
      $path .= '?' . $query;
    $destination = array('destination' => $path);
  return $destination;