Last active
August 29, 2015 14:06
-
-
Save inogo/4e9b4d7dd5939655d328 to your computer and use it in GitHub Desktop.
MODX Mobile Switch Context Plugin
This file contains hidden or 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 | |
/* see: | |
* http://rtfm.modx.com/revolution/2.x/administering-your-site/contexts/using-one-gateway-plugin-to-manage-multiple-domains | |
* "mobileContext" - mobile version context name | |
*/ | |
if (!isset($scriptProperties['mobileContext']) || empty($scriptProperties['mobileContext'])) { | |
return; | |
} | |
/* don't execute if in the Manager */ | |
if ($modx->context->get('key') == 'mgr') { | |
return; | |
} | |
/* get mobile context */ | |
$mctx = $modx->getContext($scriptProperties['mobileContext']); | |
if ($mctx) { | |
if ($_SERVER['HTTP_HOST'] == $mctx->getOption('http_host')) { | |
$modx->switchContext($mctx->key); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment