Adding a CSS file based on content type

Events happening in the community are now at Drupal community events on www.drupal.org.
badge's picture

I've created an omega subtheme, and am trying to add a CSS file only for a specific content type (confusingly called `problem'). I've tried to get to grips with the preprocess-html.inc file (I think this is what I need), but have had no you writing a suitable THEME_preprocess-html function (*trying* to use drupal_add_css).

At the moment I've butchered the html.tpl.php file thus:

    <?php if(isset($classes_array[7])) : if($classes_array[7] == 'node-type-problem'): ?>
    <style type="text/css" media="all">
    @import url("../css/menu.css");
    </style>
    <?php endif; endif;?>

How can I do this correctly? I'm at a complete loss!

Comments

You may try "Context Add

jmolivas's picture

You may try "Context Add Assets" http://drupal.org/project/context_addassets and set a contextual filter for that specific content-type

--
http://jmolivas.com/
@jmolivas

Perfect!

badge's picture

Thanks very much, does exactly what I need!

Omega Framework

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: