Welcome Guest, Not a member yet? Register   Sign In
multiple databases, multiple css files
#1

[eluser]jared4444[/eluser]
Hi,
I want to basically have one code base but use a different database and css files based on a client.

So:

www.mysite.com/client1 would look like one site and have it's own db, and
www.mysite.com/client2 would look like a totally different site

everything would work off that

the editmenu page would look like this:
www.mysite.com/client1/editmenu/1
or
www.mysite.com/client2/editmenu/1
#2

[eluser]doubleplusgood[/eluser]
Phil Sturgeon's post on his site will probably be a good place to start for you;
http://philsturgeon.co.uk/news/2009/06/H...ter-Set-up
#3

[eluser]BrianDHall[/eluser]
http://ellislab.com/codeigniter/user-gui...ation.html

Quote:Then, to globally tell the system to use that group you would set this variable located in the config file:

$active_group = "test";

And http://ellislab.com/codeigniter/user-gui...cting.html

Quote:$config['hostname'] = "localhost";
$config['username'] = "myusername";
$config['password'] = "mypassword";
$config['database'] = "mydatabase";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";

$this->load->database($config);
For information on each of these values please see the configuration page.

OK, so first you do NOT auto-load the database library. Instead in your controller/my_controller in the constructor you set the database settings and load the database manually based on what client is being requested.

You might then set a _CLIENT_ constant, and when you go to load in a view or css files you pull them from a subdirectory, such as $this->load->view(_CLIENT_ . '/main.css'). So you just make a subdirectory for each client.

If you want to be really fancy you can check to see if _CLIENT_/file exists, and if not then load a 'common' file - thus you can design a main template for everything, and then only over-ride certain files with client-specific ones if you really want to.

That's the general gist of how I'd go about it. There are surely countless more ways to do it, but this is one way that would work.
#4

[eluser]jared4444[/eluser]
thanks, but do I have to change every function to deal with that as the first parameter?

www.mysite.com/client1
#5

[eluser]jared4444[/eluser]
[quote author="Hanabi" date="1256351421"]Phil Sturgeon's post on his site will probably be a good place to start for you;
http://philsturgeon.co.uk/news/2009/06/H...ter-Set-up[/quote]

Thanks, but that isn't exactly what I was looking for. That had different domains and was for development purposes.

I mean the first parameter.

mysite.com/client 1
#6

[eluser]BrianDHall[/eluser]
[quote author="jared4444" date="1256366062"]thanks, but do I have to change every function to deal with that as the first parameter?

www.mysite.com/client1[/quote]

I would use routes to re-arrange things a bit. I believe you can do something like catch the first parameter and then remap it so as to remove it entirely, then you might be able to mung around in some global variables a bit and find how to access the original client number - this I would do in the controller or preferably my_controller. That way you could make the client setting invisible magic as far as your other controllers and functions go.
#7

[eluser]getSurreal[/eluser]
jared4444

Have you solved this? If so please post your findings.
#8

[eluser]jared4444[/eluser]
Hi, no I had not solved this problem. Sorry!




Theme © iAndrew 2016 - Forum software by © MyBB