Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am trying to add a jquery plugin to a page through drupal_add_css and drupal_add_js as follows:

drupal_add_css($path = 'sites/all/libraries/gips/css/gips.css', $type = 'file', $media = 'all', $preprocess = true);
drupal_add_js('sites/all/libraries/gips/js/gips.js', array('type' => 'file', 'scope' => 'header', 'weight' => 3));
drupal_add_js("jQuery(document).ready(function(){...dosomething...});"), array('type' => 'inline', 'scope' => 'footer', 'weight' => 5));

When I'm not aggregating/caching the CSS files, it works fine. When I try to aggregate the CSS files, it doesn't. The behavior is as if some css rules get lost in the process. The same happens even if I change the $preprocess to false.

From Chrome's code inspector, I cannot see any overriding rules getting in the way either.

I am at a loss on how to debug this. Any suggestions?

share|improve this question
1  
Please take the time to accept the answers to your previous questions, people will be much more willing to help if you do :) – Clive Feb 1 '12 at 12:24
@Clive I am not sure which answers you are referring to. Is this a generic comment or you have something specific in mind? From what I looked, I have upvoted the answers I found useful. – nikan Feb 1 '12 at 12:49
Up-voting is great but you need to actually accept the correct answer for each question. If you look at your avatar on this question you'll see you have a 0% accept rate; that's what needs to improve or people won't take the time to answer your future questions. Check the generic Meta SO post on the topic here: meta.stackoverflow.com/questions/5234/… – Clive Feb 1 '12 at 13:02
2  
@Clive Ahh! Much obliged. I wasn't aware of this. Will do right away! – nikan Feb 1 '12 at 13:25

1 Answer

up vote 3 down vote accepted

While you are using the version 7 drupal_add_js, the snippet you posted appears to be using the Drupal 6 arguments for drupal_add_css. You might also need to set the every_page option to true so that it is aggregated. Maybe try:

drupal_add_css('sites/all/libraries/gips/css/gips.css', array('type' => 'file', 'media' => 'all', 'preprocess' => true, 'every_page' => true));

You could also have a look at the group and weight settings on the api page linked above to see if they will help.

share|improve this answer
Brilliant! It worked! Thank you. – nikan Feb 1 '12 at 16:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.