Define shared variables for all sites

When you create a multi-site installation, an important table to duplicate is the variable table. However, by duplicating this table, you will also duplicate some variables that you might prefer not to. To force a set value for these variables, for all of your websites, you can do the following.

First, you will probably have a settings.php file for each site in your installation, like sites/example.com/settings.php. Edit each file and add the following to the end.

include_once ('./sites/default/shared_variables.php');

Now, in the default directory, add a file called sites/default/shared_variables.php containing the following.

<?php
/**
* These variables are fixed for all sites that have this line of
* code in their settings.php file:
*
*      include_once ('./sites/default/shared_variables.php');
*/
$conf = array(
  'site_name' => 'All these sites are belong to us.',
  'theme_default' => 'pushbutton',
  'anonymous' => 'Visitor'
);

The element names (eg. 'site_name') correspond to a variable in the variable table. So no matter how many copies of the variable table that you need, each site in your multi-site installation will defer to the variables that you define in the $conf array in your shared_variables.php file.

The disadvantage is that these variables cannot be edited via the Drupal admin pages.

 
 

Drupal is a registered trademark of Dries Buytaert.