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()?

  • 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. – kiamlaluno Jul 27 '13 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. – pown Jul 27 '13 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. – Ram Jul 27 '13 at 8:08
  • Since it didn't have any answer, you could have edited the old question. – kiamlaluno Jul 27 '13 at 8:10
  • I thought i kind of twisted that question, so tat only.Any suggestions regarding this one :) – Ram Jul 27 '13 at 8:12
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, privacy policy and cookie policy

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