Multi-site installation tips

In most cases, installing the categoryi module in a multi-site Drupal environment is a no-brainer. Usually, you just install it in the modules/ directory of your shared code base, you enable it for the sites on which you need it, and you're set to go. Even if you're using the wrapperi modules, you shouldn't really need to do anything special: just install the wrapper modules, and enable them on each site that you're also using category on.

But what happens when you want some of your sites to use category, and others to use taxonomy and book? And when, for the sites on which you're using category, you need to install the wrappers? You can't install the wrapper modules, and the original taxonomy and book modules, all in the one code base! One Drupal site cannot have two modules available to it with the same name.

Here's how you can get around this little problem, and have both the wrapper modules and the original taxonomy / book modules installed within your single-code-base multi-site setup. You do it by making use of Drupal's "site specific modules and themes within a shared codebase" feature.

Instead of installing the wrapper modules in the usual modules/ directory, you install them in a number of directories in the form sites/sitex/modules/. So if, for example, you want sitex to use category (and the wrapper modules), and you want sitey and sitez to use the original taxonomy and book modules, you would set up your files as follows:

  • sites/sitex/modules/taxonomy.module, sites/sitex/modules/book.module (where these are the wrapper modules)
  • sites/sitey/modules/taxonomy.module, sites/sitey/modules/book.module (where these are the original modules)
  • sites/sitez/modules/taxonomy.module, sites/sitez/modules/book.module (where these are the original modules)

Make sure that if you do this, you do NOT install the original or the wrapper versions of taxonomy or book in your regular modules/ directory, or in your sites/default/modules/ directory, as this will cause a conflict in that two modules with the same name will be available to one site. Each site must have access to only one file called taxonomy.module or book.module.

You can leave the category module (and co.) installed in your modules/ directory (or your sites/default/modules/ directory) - it will be available to all sites, but only enabled on some. This is better, as there will only be one copy of the category module in your code base. Unfortunately, you will have to maintain multiple copies of the wrapper modules, and the original taxonomy and book modules, because of the need to install a separate copy of these modules for each site.

Note: this document is based on a multi-site support question that was submitted to the category module's issue tracker.

Make sure that if you do

Make sure that if you do this, you do NOT install the original or the wrapperi versions of taxonomy or book in your regular modules/ directory, or in your sites/default/modules/ directory, as this will cause a conflict in that two modules with the same name will be available to one site. Each site must have access to only one file called taxonomy.module or book.module...

Unfortunately, you will have to maintain multiple copies of the wrapper modules, and the original taxonomy and book modules, because of the need to install a separate copy of these modules for each site.

Actually this is incorrect. Drupal allows site-specific modules to override any site-wide module, including taxonomy. In other words, you can leave the default taxonomy module where it is - and just make a site-specific copy for any site that wishes to use the categoryi module. The category module will overwrite the site-specific copy instead. There is no need to have any unnecessary duplicate modules.

It's all about the order in which you do things. Because of the way Drupal caches modules, if you create a site-specific module override, it won't be recognized until you actually visit the admin/modules page. So if you activate the category wrapper before Drupal officially recognizes the site-specific override, it will install the wrapper into system-wide modules directory, which of course completely borks all other sites sharing the install.

Try it for yourself, it works fine..

Install category module in the main (shared) modules directory.

For each domain that you want to use the category module follow these steps (order is important):

  1. If one does not already exist, create a site-specific 'modules' directory (i.e. /sites/example.com/modules/) and *make sure it is writeable by drupal*.
  2. Copy the main taxonomy module from 'drupal/modules/taxonomy.module' to the site-specific modules directory so that you have '/sites/example.com/modules/taxonomy.module)'. (Do this BEFORE you activate the category modules)
  3. Do the same for book.module *if applicable.
  4. Go to the admin/modules page (This will force Drupal to recognize the site-specific taxonomy.module override).
  5. Activate the category modules.
  6. Proceed to the category settings (admin/settings/category) and use the script to install the taxonomy wrapper. This should replace the site-specific taxonomy.module, leaving the site-wide taxonomy.module (and therefore all your other websites) unaffected.

See http://drupal.org/node/66897 for a complete discussion of this issue.