Don’t thank me. Thank Linux. Linux rox!
Dude - you rock! That is so freakin’ cool. It’s working great. Thanks!
Matt:
The docs are not accurate then; you can set up contexts and switch to different ones using a plugin OnWebPagePrerender or by modifying your index.php. I’ve described this in the forums, but I’ll have to search for the thread. Please bump the thread if you don’t mind and keep the conversation public.
Matt:
Here is what I was talking about, and it’s OnHandleRequest event, not OnWebPagePrerender...
header("Location: http://www.google.com");
<?php
switch ($modx->getOption('http_host')) {
case 'dev.3eimpact.com:80':
case 'dev.3eimpact.com':
// if the http_host is of a specific domain, switch the context
//$modx->switchContext('dev');
header("Location: http://www.google.com");
break;
default:
// by default, don't do anything
break;
}
?>
$modx->getOption('http_host'Well, I prefer to use $modx->log() to send information to the core/cache/logs/error.log file:
Here I got nothing. So the "case" values are not producing a match to http_host. Is there some way I could get the value of "http_host" to echo on screen so I could see what value it holds?
$modx->log(MODX_LOG_LEVEL_ERROR, print_r($modx->config['http_host'], true));
[2009-09-19 15:39:56] (ERROR @ /index.php) 3eimpact.org [2009-09-19 15:39:59] (ERROR @ /index.php) 3eimpact.org [2009-09-19 15:40:02] (ERROR @ /index.php) 3eimpact.org
Then I suppose your web server is not reporting the proper domain in $_SERVER[’HTTP_HOST’].
The error log confirmed the update on my previous post. It is seeing dev.3eimpact.com as 3eimpact.org.
[2009-09-19 15:39:56] (ERROR @ /index.php) 3eimpact.org [2009-09-19 15:39:59] (ERROR @ /index.php) 3eimpact.org [2009-09-19 15:40:02] (ERROR @ /index.php) 3eimpact.org
<?php
switch ($_SERVER['HTTP_HOST']) {
case 'dev.3eimpact.com:80':
case 'dev.3eimpact.com':
// if the http_host is of a specific domain, switch the context
$modx->switchContext('dev');
break;
default:
// by default, don't do anything
break;
}
?>