Hopefully I can explain this properly. First I've outlined my setup and below that is the question.
-----SETUP------
System Specs
--Plesk 8
--Cent OS
--php 5
--Mysql 5
--Apache 2
--Drupal 5
DNS setup
--*.domainname.com
I am setting up two website on a single installation and single database. I am planning on expanding the number of websites using that installation to 10. For now, I would like all tables to be shared between the two sites except for the variable table which stores unique elements like theme. My sites folder is setup as such:
sites/default
sites/domainname.com
sites/subdomain1.domainname.com
default settings.php database prefix settings
$db_prefix = '';
domainname.com settings.php database prefix settings
$db_prefix = array(
'default' => '',
'variable' => 'domainname_',
)
subdomain1.domainname.com settings.php database prefix settings
$db_prefix = array(
'default' => '',
'variable' => 'subdomain1_',
)
-----QUESTION/PROBLEM-----
When I do this both sites seem to work fine except when I change the template. If I log in to domainname.com and change the default theme it changes the default_theme value in the domainname_variable table like it is supposed to but when I browse to subdomain1.domainname.com it's using the same theme even though its default_theme in the subdomain1_variable table has not changed. The reverse happens when I change the theme in subdomain1.domainname.com. It's like both tables are active for both sites and the most recently changed table is the one that is used.
Here's what I mean.
domainname_variable => default_theme => theme1
subdomain1_variable =>default_theme => theme1
Both sites show the same theme (as they should). Now I log in to domainname.com and change from theme1 to theme2 and the database settngs changed to this:
domainname_variable => default_theme => theme2
subdomain1_variable =>default_theme => theme1
But now both sites are using theme2 even though subdomain1 should still be using theme1. So now I log in to subdomain1.domainname.com and change from theme1 to theme3 and the database settings change to this:
domainname_variable => default_theme => theme2
subdomain1_variable =>default_theme => theme3
Now both sites are using theme3.
Any help would be appreciated. Thank you.
P.S. (I was able to hardcode a distinct theme for each site in the settings.php using
$conf = array(
'theme_default' => 'theme1',
);
Comments
Same issue, still no solution
Jayv,
Not that it's any help presently, but I'm experiencing the exact same problem, so it can be reproduced.
I am working frantically on a solution. The subsite with its own theme is supposed to go online Monday, which is in three days.
If I find a solution I will post it here. I fear that a patch is the only way, but some logic in the settings.php for the sites may be a possible solution.
Martin
Temporary solution
I found a temporary solution to this problem. The multisite system should allow you to have "local" themes only available to the subsite. You can add a local theme by putting it in the folder /sites/subsite/themes/ and adding the theme to the $conf variable in the settings.php file for that site.
This does not work! The theme will shift as described in the original post.
The reason for this seems to be that the local theme is not loaded as a part of the available themes by the function list_themes() in theme.inc. Because of this no theme is loaded, and Drupal defaults to the basic table-based "non-theme".
For this not to happen the theme has to be globally available in the /themes folder and marked as available in the themes settings.
So to cure this problem I moved the local theme from /sites/subsite/themes to /themes and enabled it through the theme settings for the "master" site.
Now the shift works flawlessly - but the local theme has been made available to all sites, which was not the original intent.
Martin
I think the poblem is with the cache table.
I came across this post http://drupal.org/node/92675 that led me to look into the cache table and found that there is a variable field with an ugly blob with what looks like all the variable parameters crammed in there including theme information. Since I didn't prefix that table, my thought is that whenever I changed the theme on one subdomain it changed the correct variable table but also changed the main cache table which is what is actually being referenced to determine the theme for all the sites. Since there is only one cache table all sites will use the most recently updated subdomain theme regardless of what is listed in their individual variable table.
I also ended up using the settings.php table to define the theme and moved on to a more pressing issue but I will come back to this when other to-dos are solved.
Agreed
It definitely appears as if you need to prefix the cache table if you are going to prefix the variable table, or else the sites are sharing a cached version of whatever site cached its variables last.