0

I am trying to add a file which is located in sites/default/files/color/theme-768/color.css using drupal_add_css().

I have tried drupal_add_css($filepath), but it doesn't work. I tried putting it in template.php and hook_init(), but still it isn't included in the style tags of head section or anywhere.

How I do include a CSS file like this using drupal_add_css()?

7
  • This is the same question you already asked. If you have more information to add to a question, please edit it. Asking the same question more than once causes the new questions to be closed as duplicates. Commented Jul 27, 2013 at 8:02
  • @Ram I'm also struggling with the same issue for a week, I dynamically created css using color module and couldnt figure out how to include it. Commented Jul 27, 2013 at 8:02
  • @kiamlaluno: have deleted that question now, since its not been properly constructed or properly asked. can any one help with this.Now its not duplicate i think. Commented Jul 27, 2013 at 8:08
  • Since it didn't have any answer, you could have edited the old question. Commented Jul 27, 2013 at 8:10
  • I thought i kind of twisted that question, so tat only.Any suggestions regarding this one :) Commented Jul 27, 2013 at 8:12

1 Answer 1

0

I found a alternate way to include css file which is in some other location other than modules and themes.In my case including a dynamically generated file. Even though i can't find a way through drupal_add_css(),this helped me in adding css.

This is the way i included dynamically generated css file which is located at sites/default/files/color/theme-768/color.css

In the theme folder in the html.tpl.php after <?php print $styles;?> include this

<?php    
       print '<style>';
       print '@import url("' . $filepath . '")';
       print '</style>';
?>

This includes the css file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.