Last active
April 23, 2022 17:05
-
-
Save intersel/442a55761b6df02334590f4db0bd2abe to your computer and use it in GitHub Desktop.
MODX snippet to redirect a page to another URL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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