I'm sure I'm not the first person to come up against this issue, but I have not managed to find a simple solution yet. I have a number of sites on a multi-site installation, some of which use the Garland theme. Most of these Garland-based sites need a few minor CSS tweaks but do not (yet) need the full flexibility afforded by having their own Garland-derived themes separate from the global site's Garland.

I just don't see a good way to do this. So far, I have been copying Garland into each site's themes directory and just adding an extra stylesheet import to page.tpl.php. The obvious problem with this scenario (aside from the overhead of copying the entire theme) is that when the global site's themes are updated (when a new release of Drupal comes out), then I have to go through each site and merge in any changes to Garland.

I can picture a few ways to go about this, but it seems like somebody must have solved this problem in some way. One approach would be to develop a very simple module that did nothing but do a drupal_add_css in whatever hook makes sense. Another approach would be to just modify the global Garland theme to include (if it exists) a file in a predictable location, like drupal/sites/[sitename]/files/custom.css.

The (brand new?) Alter CSS module does not seem to be designed with this multi-site scenario in mind. I noticed in my Googling that Bryght has an option that seems to be exactly what I want, but I can't tell if that's coming from some module I might be able to use on my own site.

Any suggestions?

-Steve

Comments

dvessel’s picture

Copy Garland into "sites/all/themes", do your mods and assign all your installations to that theme.. done.

HorsePunchKid’s picture

Unfortunately, not all of the sites use the same customizations; otherwise, that would be fine. What I need is a way to make purely CSS customizations without forking the theme for each site. Thank you, though, for the suggestion.

dvessel’s picture

Then copy Garland over and add this bit inside template.php.

if (file_exists($custom_css = conf_path() .'/custom.css')) {
  drupal_add_css($custom_css);
}

Then inside each install place your custom.css and it'll pick it up.

for example:
"sites/example.com/custom.css"
"sites/sub.example.com/custom.css"
etc..

Each install will load their own custom style sheet.

HorsePunchKid’s picture

But forking Garland for every site I create is exactly what I'm trying to avoid (refer back to my original post for why). I have modified the global Garland very similarly to what you suggest as a short-term hack awaiting a better solution:

--- themes/garland/page.tpl.php 2007-09-22 20:47:48 +0000
+++ themes/garland/page.tpl.php 2007-07-29 21:39:04 +0000
@@ -10,9 +10,6 @@
     <!--[if lt IE 7]>
     <style type="text/css" media="all">@import "<?php print base_path() . path_to_theme() ?>/fix-ie.css";</style>
     <![endif]-->
-    <?php if(file_exists(file_directory_path()."/custom.css")): ?>
-      <style type="text/css">@import "<?php print base_path() . file_directory_path() ?>/custom.css";</style>
-    <?php endif ?>
   </head>
   <body<?php print phptemplate_body_class($sidebar_left, $sidebar_right); ?>>

Thus I can at least use this custom.css when I need it, and I only have to merge updates to Garland into one copy of it. But this same idea of wanting to do trivial CSS customization really applies to any theme I might use; hence a module is probably a more appropriate solution. The eventual goal, if I didn't point it out yet, is to also be able to update this CSS file via a Drupal form; but again, I'm thinking I can't possibly be the first person to want to do this.

Thanks again for your help!

Cheers,
-Steve

rondp’s picture

Thanks for the snippet - I believe this should work without copying Garland anywhere.

Haven't tried it, though, because I prefer a solution without hacking core files (and without copying them), but have submitted a feature request to the Garland project to allow for an optional custom CSS file.

Quoting your post for a code example - I hope you don't mind! ;-)

rondp’s picture

It would be great if that was part of the template engine, meaning that in order to override any style in any theme, you'd just drop your own "custom.css" into place and be done. My feature request for Garland was moved to "theming system", which seems to be the right place, but then just closed as "won't fix" with a pointer to the "CSS Injector" module. Which is a nice module but says itself that it cannot override theme styles (other than by using the !important flag, which is not always appropriate.)

Not sure where and how to put that suggestion up such that the right people will consider it.

Any ideas?

Cheers,

Ronald

HorsePunchKid’s picture

I've written a simple module to do this for me. I will post it in a little while here, once I have a chance to look it over again, make sure it's documented and conforms to the Drupal manual of style, and package it up.

-Steve

HorsePunchKid’s picture

Volo Broadband has sponsored development of the module, and you can download the Simple CSS module here. Comments and suggestions welcome!

-- Steven N. Severinghaus <steve@volo.net>

Dave Reid’s picture

What about the CSS Injector module? Nevermind...it was created after you wrote your small module.

Senior Drupal Developer for Lullabot | www.davereid.net | @davereid

kwurzel’s picture

I think it's very easy with Drupal 6.x. You can just make a themes/garland directory in every site's folder (i suppose you just did so), copy just the original garland.info in there, select original Garland (in sites/all|default/themes/Garland) as your parent (?) theme and then add your own css-file in the info-file.

I didn't test this, so it may not work...

Julius

rondp’s picture

kwurzel, thanks for the suggestion.

I've played around with it a bit and this is the most efficient way I found to both apply my custom css tweaks and keep the functionality of the original garland theme:

Step 1

cd sites/all/themes
mkdir garland_tweaked # don't call this "garland"!!
cd garland_tweaked
cp ../../../../themes/garland/minelli/minelli.info garland_tweaked.info  # don't keep the name "minelli.info"!!

edit garland_tweaked.info to suit - I made it include custom.css and replaced the description = ... line with that from garland.info.

put your custom.css into place.

This works for me and applies the tweaks from the custom css to the basic version of garland, i.e. the blue one, however the functionality to tweak the colours is gone. This is one way to get it back:

Step 2 (optional)

ln -s ../../../../themes/garland/* .
rm garland.info  # don't keep this around!!

Done.
Cool, and if only for the learning effect - many thanks again for pointing out the general approach - I wasn't aware that sub-theming could be so simple.

I may also try the method outlined by dvessel in comment #3 above - shouldn't that also work without the copying-over part? In that case it would seem much easier to do and just as flexible, the drawback being that the patch needs to be re-applied with every new version of Drupal and/or Garland. (Hm, maybe worth a feature request for the garland theme.)

With my approach, as long as the number and names of files/directories in the garland directory don't change it would require no changes. And it fits in nicely with the way I manage my Drupal and module installations in the first place - don't you just love symbolic links! :-)

nerkn’s picture

I need to style my view. This is one line change because of that I cant bother my self symbolic linking, creating undeployed version etc.

What I found is
I did code into header section of the view (php code of course)
<style> .views_slideshow_div_breakout_teaser{ display:inline;} </style>
By extending that thougt, I'll make a block for my styles.
Thanks theme developers for that monkey work

sarkisozu.web.tr