How are you calling the Snippet? It must be uncached to return different results. Also, REQUEST_URI is not portable; consider developing in a subdirectory. Instead, you might try this without including the initial slash:
<?php
$homepage = "";
$ohio = "states/oh";
$illinois = "states/il";
$michigan = "states/mi";
$currentPage = $_REQUEST[$modx->getOption('request_param_alias')];
However, consider this is not cacheable and there might be more efficient ways to accomplish this. One thing that comes to mind is having a TemplateVar with the state initial which is simply fed to the Snippet call, e.g.
[[GetPhone? &state=`[[*state]]`]]
Then your code would be cacheable on each Resource and would not be dependent on the URI's.
<?php
$output = "";
$state = empty($state) ? "" : $state;
switch ($state) {
case 'oh':
$output = "555-555-5555";
break;
case 'il':
$output = "555-555-5556";
break;
case 'mi':
$output = "555-555-5557";
break;
default:
if ($modx->resource->get('id') == $modx->getOption('site_start')) {
$output = "1 (800) 555-5555";
}
break;
}
return $output;
[ed. note: opengeek last edited this post 15 years, 2 months ago.]