Skip to content

Instantly share code, notes, and snippets.

@MatthieuScarset
Created February 25, 2016 10:37
Show Gist options
  • Save MatthieuScarset/d7860328118136ab143c to your computer and use it in GitHub Desktop.
Save MatthieuScarset/d7860328118136ab143c to your computer and use it in GitHub Desktop.
Drupal - Go to error page
/*
* Redirect to error page
* @param $site string Wether is for mobile or desktop site
* @param $err_code int Error code
* @param $path bool|string Force a path for redirection
* @see http://www.kobashicomputing.com/creating-custom-drupal-6-error-pages
* @return header()
*/
function _goto_error_page($site = 'mobile', $err_code = 404, $path = false) {
$variable_name = ($site == 'mobile') ? "site_mobile_$err_code" : "site_$err_code";
$location = $path ? $path : drupal_get_normal_path(variable_get($variable_name, $path));
header('Location: /' . $location);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment