Saturday, 30 May 2015

How to include css and js files in theme info file?

It could be possible to include js and css files in theme info file itself, eventhough, those are not in themes folder.
One more thing, if we include these files through link / script tags, while doing aggregation (cache), DRUPAL wont cache those files.
Ex:
stylesheets[all][] = ../../../default/files/styles/style.css
stylesheets[all][] = style1.css
conditional-stylesheets[if IE 7][all][] = ../../../default/files/styles/style_ie7.css
conditional-stylesheets[if IE 8][all][] = ../../../default/files/styles/style_ie8.css

scripts[]= ../../../default/files/javascript/AC_RunActiveContent.js
scripts[]= ../../../default/files/javascript/swfobject.js
In the above ex, style.css file is in a folder which is in sites/default/files ... path. 
It is similar in case of scripts too.
And we can see the way to include conditional style sheets for IE browser.  This could be possible with Conditional Styles module.  For more info, http://drupal.org/project/conditional_styles

No comments:

Post a Comment

Your comment is so valuable as it would help me in my growth of knowledge.