is it possible on mutli-site to share one theme but using different style id's

darumaki - July 27, 2008 - 20:31

At first glance, I don't see how this can be done since the page/node.tpl is part of each theme, the idea behind this is to use same theme but have different backgrounds for each site.

You could add some logic in

pbull - July 27, 2008 - 20:56

You could add some logic in your page.tpl.php file that adds a class to the body, based on some unique value such as $site_name or $base_url. For example:

<?php
$site_class
= strtolower(str_replace(' ', '-', $site_name));
?>

and then:

<body class="<?php print $site_class; ?>">

I'm not sure I follow you,

darumaki - July 27, 2008 - 23:25

I'm not sure I follow you, like this ?

<?php
$site_class
= strtolower(str_replace(' domain1.com', 'bodyclass1', $base_url));
?>

<?php
$site_class
= strtolower(str_replace(' domain2com', 'bodyclass2', $base_url));
?>

<body class="<?php print $site_class; ?>">

Well, ignore the $base_url

pbull - July 28, 2008 - 00:58

Well, ignore the $base_url example since that's more work to strip out the "http://" and forward slashes. Just focus on using $site_name for now.

For example, if you have one site named "My First Site" and another named "My Second Site", then using the code I provided above, the body tag pages on those site would include a class of "my-first-site" and "my-second-site", respectively.

Then you can address use those classes to modify elements in your css:

body.my-first-site .block {
  color:#000;
  background-color:#fff;
}
body.my-second-site .block {
  color:#fff;
  background-color:#000;
}

Not working,

darumaki - July 28, 2008 - 08:36

Not working,
I have it setup like this in page.tpl.php but the classes are not getting pulled.

<?php
$site_class
= strtolower(str_replace('site name1', 'site name2', $site_name));
?>

is the site name in the code and class case and space sensitive ?

Update: I got it working a little, but when I put 2 sites into the code, it only outputs one site for css, the above code can have 2 sites correct ? Or does it have to do with the other site having spaces inbetween.

Next Update It seems to be working using multiple instances for each site

<?php
$site_class
= strtolower(str_replace(' ', 'site-name', $site_name));
?>

For some reason it only works by having the first item empty ' '

the site name appears to be case sensitive no spaces. Is there a way to enter the site name as is like 'site name', body.site name, I got the one to work only by adding dashes the-site-name,

Another Update ok, I think I understand how your code above is suppose to work, just leaving the code as is with '-' is enough to pull in the class, the only thing is, it won't work when the site name is more than 1 word, ie 'site name' won't work but 'site' will. anyway around this ? It seems kind of strange that it won't work with more than one word, I suppose I could try to use dashes for the site name but that won't look very good on the site.

why not base_url?

pulpzebra - July 28, 2008 - 08:56

I believe that base_url wasn't that bad. URLs cannot have spaces or non-standard characters, so this could be the better choice to work around your problem. If you want to keep it simple, just replace any www. in front or any suffix: explode the baseurl at the '.' (dot), discard the last element and grab the previous one: eg. www.region.mysite.com you get 'mysite'

How would the code look if

darumaki - July 28, 2008 - 19:02

How would the code look if using base_url ? The above code creates the body classes but with base_url how would that work ?

I managed to get the

darumaki - July 31, 2008 - 06:08

I managed to get the $site_name to work by putting " " around site name in admin, this creates a useable css that outputs my-site-name. The downside it shows the meta page title as "My Site Name", something I'll have to live with until I can figure out another solution.

 
 

Drupal is a registered trademark of Dries Buytaert.