Community Documentation

Setting up a virtual site

Last updated April 25, 2008. Created by fokkezb on April 25, 2008.
Log in to edit this page.

Understanding the Virtual Site module

What the Virtual Site module does is basicly overriding Drupal settings. This is also what Drupal's multi-site feature does at core-level (bootstrap), but than at run-time level (hook_init()). This difference is why Virtual Site cannot change database settings, because these are already initialized when Virtual Site comes in.

Understanding a single Virtual Site

Each Virtual Site you create can be seen as a group of settings to override Drupal settings with. To determine when which Virtual Site settings are applied, the module depends on the Condition module. A condition can be seen as a group of requirements. When all requirements are met, the condition is TRUE.

A real-life example

Let's say I want to have a different theme and site title for all pages that have a path alias starting with subsite/.

  • Install both the Virtual Site and the Condition module.
  • Go to admin/settings/condition/add and choose a name.
  • Expand Requirement: Pages, set Validate to Only... and enter subsite/*.
  • Press Save settings.
  • Go to admin/build/sites/add and choose a name.
  • Set Criteria to When ANY selected condition is met.
  • Check the newly created condition and press Save settings.
  • Find the newly created virtual site in the list and click the edit link.
  • Go to the Information tab, change the default site name and press Save settings.
  • Go to the Theme tab, select a theme and press Save settings.
  • Optionally, change any theme settings and press Save settings.
  • Create or go to a page having an alias starting with subsite/.

Handling multiple (sub)domains with Virtual Sites

Just like with Drupal's multi-site feature, the key is to point all the (sub)domains to the main public HTML directory. You can ask your host to point all domains to the same public HTML directory or use symbolic links. Once set, you can create a new condition for every domain and use the hostname requirement to enter the domain you want the condition to be valid for.

Comments

not working

Followed these instructions, but cannot get it to work. I've set the condition, added the virtual site, but it still comes up as my main site.

any ideas? I'm running 10.6.2, mamp.

I just did this and have got

I just did this and have got it changing, but no blocks appearing. Here is what I did differently than above:

* In the condition module, be sure the condition for your virtual site is listed above your main site.
* In the virtual sites module, be sure the new virtual site is listed above your main site.
* The theme tab didn't work for me in the virtual sites module, but this text in the variables tab did work:
theme_default=my_theme
admin_theme=garland

I'm guessing my third bullet is somehow the answer to my blocks not appearing, just don't know where to find the variables to use to set them to appear.

I don't get this

I've followed the example above to set up a virtual site, on the basis of pages with a path alias starting with subsite/.
However, I don't understand how I can create content for that subsite. In the "create content" form, there isn't anything (as far as I can see) that allows me to define what virtual site this content will be used in...

Looks like you should be

Looks like you should be using the same "Create Content" link sitewide, just that by specifying a path alias like subsite/my-new-page, VirtualSite will render the elements and settings you chose for the Virtual site called "subsite"

Registered Linux User #370740

I run cron and my problem was

I run cron and my problem was fixed.

About this page

Drupal version
Drupal 6.x
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.