This is what the assign_to_config
array in your main index.php file is for (assuming you're not using something like FocusLab Master Config, which makes multi-environment really easy). If you don't want to use that approach, the quick way is to just crack open your index.php file, scroll down to the bit where assign_to_config
gets set, and create some global variables based on, say, the $_SERVER['HTTP_HOST'] var.
Here's a quick example using a switch statement to determine local/dev/live environment and setting some global variables accordingly (I use this as a quick and easy method for displaying draft content on the dev site):
switch($_SERVER["HTTP_HOST"]) {
case "dev.site.com" :
$assign_to_config['global_vars']['gv_site'] = 'dev';
$assign_to_config['global_vars']['gv_entry_statuses'] = 'open|Draft';
$assign_to_config['site_url'] = "http://dev.site.com/"; // if you don't set this, it's taken from the database instead
break;
case "www.site.com" :
case "site.com" :
$assign_to_config['global_vars']['gv_site'] = 'live';
$assign_to_config['global_vars']['gv_entry_statuses'] = 'open';
break;
case "site.dev" :
case "localhost" :
$assign_to_config['global_vars']['gv_site'] = 'dev';
$assign_to_config['global_vars']['gv_entry_statuses'] = 'open';
$assign_to_config['site_url'] = "http://site.dev/";
break;
}
You can then use {gv_site}
anywhere in your templates.