Welcome Guest, Not a member yet? Register   Sign In
Multiple Versions of Same Site
#1

[eluser]Unknown[/eluser]
Currently I have 2 different websites that run off the same exact framework. It doesn't make sense to install CodeIgniter in two different directories that should be using the same code.

Although the code to grab pictures and everything is the same, what needs to be different is the page titles, headers, etc...

On my current site (not on CodeIgniter) - I set a public variable as a boolean in my main controller by doing a "strstr" on my $_SERVER['SERVER_NAME'].

If the public boolean variable is 1 then it knows the set the page title to "Random Site 1" otherwise if it's 0 it defaults the page title to "Random Site 2";

How can I take take advantage of using the same class functions (with only minor changes depending on the site) in the most efficient way possible using Code Igniter?
#2

[eluser]pistolPete[/eluser]
I'd suggest using two databases with the exact same layout but different content.

Set a constant (instead of the public varible) in index.php:
Code:
define('SITE_SWITCHER', ($_SERVER['SERVER_NAME'] == 'your-domain.com'));

Now set the configuration according to the constant:
Code:
/* Location: ./system/application/config/config.php */
if (SITE_SWITCHER)
{
    $config['base_url']    = 'http://your-domain.com/';
}
else
{
    $config['base_url']    = 'http://the-other-domain.com/';
}

/* Location: ./system/application/config/database.php */
if (SITE_SWITCHER)
{
    $db['default']['database'] = 'yourdomaincom';
}
else
{
    $db['default']['database'] = 'theotherdomaincom';
}




Theme © iAndrew 2016 - Forum software by © MyBB