Welcome Guest, Not a member yet? Register   Sign In
Questions on serving same code base to multiple sites
#6

[eluser]J Maxwell[/eluser]
Ok, thats what I thought - so:

The first thing I suggest is having a good look at DataMapper DMZ - once you use ORM, and DMZ is a lovely example of it, you won't ever want to go back.

The outline of the way I would do it is this:

Consider your database design carefully - I suggest using MySQL Workbench (free) to create ERR models which really help to visualise it.

Basically you have a site model that owns all of your other models, so say in your pages table, you can have page1 owned by site1, page 2 owned by site2 etc.

Some CI ideas:

1. Point all domain names to the same server.
2. Set your base_url in config.php to be $_SERVER['SERVER_NAME'], and consider some form of decontamination on it.
3. In your sites table save a 'domain' field with each sites details
3. In a MY_Controller, load your site into a new object -
Code:
$this->s = new Site()
$this->s->get_by_domain($this->config->item('base_url');
4. Then from this object you can do whatever you need, for example in a posts controller, you could do:
Code:
function display($id) {
$this->s->p = new Post($id);
$this->load->view($this->s->template.'/posts', $this->s->p);
}
That would load a new post from the the site that was requested, then load the view 'posts.php' in the template folder defined in the original site model.

Anyway - that might give you an idea how to start out? Try searching on here for Database driven routes as well, that can offer some neat features for ensuring that each site has the desired features.

Hope that helps some!

John

[EDIT = error in codeblock. Ooops]


Messages In This Thread
Questions on serving same code base to multiple sites - by El Forum - 08-18-2010, 03:31 PM
Questions on serving same code base to multiple sites - by El Forum - 08-18-2010, 07:04 PM
Questions on serving same code base to multiple sites - by El Forum - 08-19-2010, 02:32 PM
Questions on serving same code base to multiple sites - by El Forum - 08-19-2010, 02:47 PM
Questions on serving same code base to multiple sites - by El Forum - 08-19-2010, 03:17 PM
Questions on serving same code base to multiple sites - by El Forum - 08-19-2010, 04:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB