tags:

views:

197

answers:

1

Drupal 6 has a wonderful CSS and JavaScript aggregator. Unfortunately, it interferes with development as it's only regenerated when you clear the Drupal cache.

I'd like to turn it on for non-admins (to save HTTP requests) but have the individual CSS and JS files served directly to admins for development. Has anyone done this? Is it possible?

+4  A: 

That's an interesting idea. Since the aggregation settings are stored in Drupal variables, and those are read into the global $conf array during bootstrapping, I tried the following in a modules hook_init() implementation:

global $user;
if (1 == $user->uid) {
  global $conf;
  $conf['preprocess_css'] = FALSE;
  $conf['preprocess_js'] = FALSE;
}

So far this just works :)

Now I'm suspicious - according to my standard experience over the years, if something is that simple on first sight, it will break down horribly sooner or later ;)

But right now the worst thing I can imagine happening with this is that it just fails in situations where for some reason or the other the $conf array gets repopulated during a page cycle, in which case the admin would just get the cached versions again.

Henrik Opel
Wonderful, thanks. Seems to be working, 'though I hear ya on the suspicion! :-)
ceejayoz

related questions