Skip to content

Instantly share code, notes, and snippets.

@intersel
Last active April 23, 2022 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save intersel/442a55761b6df02334590f4db0bd2abe to your computer and use it in GitHub Desktop.
Save intersel/442a55761b6df02334590f4db0bd2abe to your computer and use it in GitHub Desktop.
MODX snippet to redirect a page to another URL
<?php
/****************************************************
Redirect the page to another URL
Parameters:
- gotoURL : a resource ID or an URL
- dontGoto : default:false, if true, do nothing...
Usage:
[[GotoURL? &gotoURL=`10` &dontGoto=`1`]]
[[GotoURL? &gotoURL=`http://www.intersel.fr`]]
****************************************************/
$dontGoto = empty($dontGoto)? false:true;
if ($dontGoto || empty($gotoURL)) return;
if ( !is_int($gotoURL) ? (ctype_digit($gotoURL)) : true )
$gotoURL = $modx->makeUrl($gotoURL);
$modx->sendRedirect($gotoURL);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment