Skip to content

Instantly share code, notes, and snippets.

@nathanpitman
Created September 20, 2012 21:22
Show Gist options
  • Save nathanpitman/3758435 to your computer and use it in GitHub Desktop.
Save nathanpitman/3758435 to your computer and use it in GitHub Desktop.
An ExpressionEngine plug-in to allow you to manually switch sites through the front end.
<?php
$plugin_info = array(
'pi_name' => 'Change Site URL',
'pi_version' =>'1.0',
'pi_author' =>'Nine Four Ltd',
'pi_author_url' => 'http://www.ninefour.co.uk/labs/',
'pi_description' => 'Changes the current site URL.',
'pi_usage' => Change_site::usage()
);
class Change_site
{
function Change_site()
{
global $DB, $PREFS, $TMPL;
// Get site id
$site_id = $TMPL->fetch_param('site_id');
$query = $DB->query("SELECT site_name, site_system_preferences, site_pages FROM exp_sites WHERE site_id = ".$site_id);
$site_system_preferences = unserialize($query->row['site_system_preferences']);
$PREFS->core_ini['site_id'] = $site_id;
$PREFS->core_ini['site_url'] = $site_system_preferences['site_url'];
$PREFS->core_ini['site_pages'] =& unserialize($query->row['site_pages']);
}
// usage instructions
function usage()
{
ob_start();
?>
-------------------
HOW TO USE
-------------------
<?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment