I did this a little differently on my site
http://sqrville.org/ when I added the "sub-site"
http://sp.sqrville.org/. The latter produces the same content as the former but it focuses on just a few (related) topics. Most of the blocks are customized for the sub-site. As you can see I haven't added much to it yet, but it works.
The way I set it up is very similar to the FAQ linked above, but I added a global variable $_SITE that gets set based on the requested hostname, which the individual php functions use to tell which type of content to serve. Instead of multiple config.php's I added this to my existing config.php:
Text Formatted Code
// +---------------------------------------------------------------------------+
// | (2.5) Multi-site hack by Chris |
// +---------------------------------------------------------------------------+
if( $_SERVER['SERVER_NAME'] == 'sp.sqrville.org' ) {
$_SITE = 'sp';
} else {
$_SITE = 'default';
}
// +---------------------------------------------------------------------------+
// | (3) Site Settings |
// +---------------------------------------------------------------------------+
// Make sure this is the correct URL to your site, i.e. to where Geeklog's
// index.php file resides (no trailing slash).
if( $_SITE == 'sp' ) {
$_CONF['site_url'] = 'http://sp.sqrville.org';
// Some hosting services have a preconfigured admin directory. In that case,
// you need to rename Geeklog's admin directory to something like "myadmin"
// and change the following URL as well. Leave as is until you experience any
// problems accessing Geeklog's admin menu.
$_CONF['site_admin_url'] = $_CONF['site_url'] . '/admin';
// This is the return address for all email sent by Geeklog:
$_CONF['site_mail'] = 'sp-admin@sqrville.org';
// Name and slogan of your site
$_CONF['site_name'] = 'sp.sqrville.org';
$_CONF['site_slogan'] = 'news about smashing pumpkins, billy corgan, jimmy chamberlin and friends';
} else {
$_CONF['site_url'] = 'http://sqrville.org';
// Some hosting services have a preconfigured admin directory. In that case,
// you need to rename Geeklog's admin directory to something like "myadmin"
// and change the following URL as well. Leave as is until you experience any
// problems accessing Geeklog's admin menu.
$_CONF['site_admin_url'] = $_CONF['site_url'] . '/admin';
// This is the return address for all email sent by Geeklog:
$_CONF['site_mail'] = 'admin@sqrville.org';
// Name and slogan of your site
$_CONF['site_name'] = 'sqrville.org';
$_CONF['site_slogan'] = 'deader than red bats';
}
There is a similar if statement for the theme later on in the config.php but the rest of the changes are in other parts of the core code. Since the content was all coming from the same site I just used the same database and tables. I also left all the cookie settings the same, so that if a user logs in on one site they are logged in on the other site too.
The main reason for doing it this way is keeping it relatively easy to have one site that shows content from all the sub-sites, which would be difficult (correct me if I'm wrong) for separate databases or even separate table prefixes.
The next thing I'd like to do with this is to scale it so that you can add multiple site support for any number of sites and store the settings for how each one is layed out in the database.
Does anyone have any ideas on how to go about implementing this? I was thinking of adding columns to some of the geeklog tables that would specify which sites each row of information is visible on. For instance, blocks would have a selector box in the administration menu allowing the admin to select all, main only, subsite 1, subsite 2, etc. Similar settings would be avaible for forums. Stories can remain as I have them now - the sub-site displays a collection of topics, including the stories marked not to appear on the home page. In this way the sub-sites can 'syndicate' news from the main site, and vice-versa, while also having its custom topics. The main site would include all news from all sites that is not marked as show on main page.
Of course the farther i get into this the harder it is to backport Geeklog releases and updates into my codebase as well as my database. I haven't done much plugin coding yet, perhaps I need to look at the Documentation and try that...but something tells me there are too many changes to the core code to have a plugin that effectively does all this.
I am going to be implementing this on a larger scale on another site soon, actually I hope to be setting up a multi-site and then merging the databases of some existing sites into it, then adding some more. If I get far enough in my coding I'd like to release my work to the community, somehow...
So if any of you guys have some suggestions on how I should go about any of this, or if you think I'm a rambling lunatic, let me know what you think.