Community Documentation

Define shared variables for all sites

Last updated June 26, 2009. Created by sime on June 23, 2006.
Edited by bryan kennedy. Log in to edit this page.

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.

About this page

Drupal version
Drupal 4.6.x, Drupal 4.7.x, Drupal 5.x
Drupal’s online documentation is © 2000-2012 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.