multiple databases, multiple css files - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: multiple databases, multiple css files (/showthread.php?tid=23857) |
multiple databases, multiple css files - El Forum - 10-23-2009 [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 multiple databases, multiple css files - El Forum - 10-23-2009 [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/How-to-Multi-site-CodeIgniter-Set-up multiple databases, multiple css files - El Forum - 10-23-2009 [eluser]BrianDHall[/eluser] http://ellislab.com/codeigniter/user-guide/database/configuration.html Quote:Then, to globally tell the system to use that group you would set this variable located in the config file: And http://ellislab.com/codeigniter/user-guide/database/connecting.html Quote:$config['hostname'] = "localhost"; 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. multiple databases, multiple css files - El Forum - 10-23-2009 [eluser]jared4444[/eluser] thanks, but do I have to change every function to deal with that as the first parameter? www.mysite.com/client1 multiple databases, multiple css files - El Forum - 10-23-2009 [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/How-to-Multi-site-CodeIgniter-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 multiple databases, multiple css files - El Forum - 10-23-2009 [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. multiple databases, multiple css files - El Forum - 12-18-2009 [eluser]getSurreal[/eluser] jared4444 Have you solved this? If so please post your findings. multiple databases, multiple css files - El Forum - 12-18-2009 [eluser]jared4444[/eluser] Hi, no I had not solved this problem. Sorry! |