I´m not sure if this is the (only) reason why it wasn´t working on my site, but this is how i got it work, in case it helps anyone.

I was adding some CSS in my preprocess_page such as:

drupal_add_css(path_to_theme() . '/css/mycss.css', "theme");
$vars['styles'] = drupal_get_css();

So my guess is the styles were being defined after the module has run, thus "overwriting" it. I added an addictional call and it´s working so:

//in phptemplate_preprocess_page(&$vars, $hook)

drupal_add_css(path_to_theme() . '/css/mycss.css', "theme");
$vars['styles'] = drupal_get_css();
if (module_exists('unlimited_css')) {
unlimited_css_preprocess_page($vars);
}

My guess is the module needs to be after any operations on $vars['styles']... Am I right?.

Comments

donquixote’s picture

Did you try the same without this module?
I think hook_preprocess_page() is always too late for drupal_add_css(), no matter if you use unlimited_css or not.

You should rather use your theme's *.info file, or in case of modules, a hook that is run before preprocess_page().

See
#891832: Stylesheet handler to replace drupal_add_css() and the stylesheets array in page.tpl.php.

lucascaro’s picture

The same here. If you need to add styles in your theme's preprocess page (when it's a style sheet you need in only one page, for example), you need to get the styles again using drupal_get_css(). Doing this will undo the changes from this module, unless we call the preprocess function again..

donquixote’s picture

If you need to add styles in your theme's preprocess page (when it's a style sheet you need in only one page, for example)

There are other ways to do that.
One is using pageapi module, and implement hook_pageapi() in your theme.

function mytheme_pageapi($api) {
  if ($_GET['q'] === 'path/of/destiny') {
    // If the CSS is in your theme.
    $api->css('css/mytheme.css');
    // If the CSS is somewhere else.
    $api->css('css/foo.css', 'module:foo');
    $api->css('css/cycle.css', 'library:jquery_cycle');
  }
}

See
http://drupalcode.org/project/pageapi.git/blob/1efa31e535d2aa225e8b48132...

lucascaro’s picture

great!
Just in case someone doesn't know what hook_pageapi is, it's provided by a contrib module created by @donquixote at http://drupal.org/project/pageapi

thanks!