views:

67

answers:

3

Hi All,

I am looking for expert advice on how to best serve multiple sites with one Drupal instance (using Pressflow 6.x). Let's consider the company needing this is called "ABC Group of Companies" and it has 3 sister concerns. So, altogether there will be four sites:

  1. www.abcgroup.com
  2. www.company-a.com
  3. www.company-b.com
  4. www.company-c.com

Here are the things that are most interesting:

  • The users will be shared among all the sites
  • Each site will "mostly" host their own content (say the welcome text on home page, or menu items - different for each site)
  • Some contents, will be shown in all of the sites (say, a company-wide notice....or an employee directory)
  • The theme for each site will be different

Now, I am thinking of having DNS entry so each of the domain point to the same Drupal installation and when Drupal gets bootstrapped, I would like to sniff into the $_SERVER array to know which site is being hit. I'd then like to load the theme accordingly, show the contents specific to that site, and also show the contents that are shared with all the sites.

To make this happen, so far I have created a node type called "Site" and have created four contents for each of the sites. Then for each other content type (say, Page) I have put a node reference to the "Site" content type with multiple value so when creating a new content, the administrator can specify in which site that content will be showed. However, after that I am stuck.

I have tried to understand Contexts, Spaces, PURL - but haven't figured them out fully yet and I believe I could use the community power to help me out. What do you think is the best approach to handle this scenario ?

It'd be greatly helpful if anybody can suggest a direction.

Regards,

Emran

+5  A: 

The way you are suggesting is certainly a way that you could do it, but have you considered domain access? I have used it in the past and found it to be very useful. there is also quite a large collection of modules which work with it. Different themes, Options as to which nodes should appear on which sites and shared users are all features that it has.

Hope this helps!

http://drupal.org/project/domain

hookd
+1 Good advice - doing this oneself is certainly possible, but a lot of work that might better be spent elsewhere ;)
Henrik Opel
Thanks...the domain access module seems to solve most of my headache !!!
phpfour
+4  A: 

First up, I strongly second hookds suggestion of using Domain Access Module for this (+1). It has extensive support/features for your scenario and already covers most of the hard parts you'd need to solve yourself otherwise.

Second, if you insist on trying to do this yourself, I can assure you that it is possible, as we have done something pretty similar recently (some special requirements ruled out domain access), but it was a lot of work, especially when functionality provided by contributed modules would not fit well into our 'unusual' scenario.

Given the multitude of special cases you'd have to cover, it is hard to point out a general direction (apart from suggesting to use Domain Access Module ;) but one major point would be to check out the custom_url_rewrite_inbound()/custom_url_rewrite_outbound() function combo. These will allow you to do pretty low level URL manipulations for incoming requests, as well as for URLs generated for output, both of which you'll need to do if you you want to serve multiple domains from the same instance.

Did I mention that you should check out Domain Access Module before you try to build this yourself?

Henrik Opel
Domain Access is the way to go. Very stable. I used it for a 12 city website that needed to be served one database, i.e. on article could be published to multiple markets.
awats
Also, if you're planning on creating blocks for these sites. You'll need the Domain Blocks companion module. http://drupal.org/project/domain_blocks Otherwise your blocks will be served to all domains.
awats
+1 Thanks to Henrik as well, I'll be sure to check the custom_.... functions if domain access fails for any scenario, but so far looking very good.
phpfour
A: 

It sounds like there will be virtually no content shared between these sites. Will you be wanting a single login across all sites? Remember, Domain Access uses 1 shared database. You could also just do a regular multi-site install, and share certain tables.

I give Domain Access two thumbs up, but just make sure you really need what it actually does.

Also, I would look into the Feeds.module. You can pull content from anywhere (especially another drupal site) and it imports it directly and creates nodes and fields automatically from it.

picxelplay