Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By Duplika on
Hello guys,
I'd like to add some CSS to a couple of nodes. Is there a way to add a css file to those nodes only?
Comments
Taxonomy theme
Taxonomy theme ?
------------------------------------------------------
Be Smart, Think Free, Choose OpenSource.
A couple of other ways
You do not say what or how you want the css different so this may or may not work for you need. One way is to use a different content type for those "special" nodes. If you just want different css for that type you could modify the line in node.tpl.php that looks something like
and add a class to show node type (print 'node-' . $node->type;) change the line to (note that your themes node.tpl.php maybe different)
Now you can add css rules that depends on node type (I will use page for the example) and add rules for the various elements using the type, something like
If you only want a few nodes themed different and can't (or don't want to) use a different content type you could change the line so it uses the nid (print 'node-' . $node->nid) as part of a class name, something like
Now you can add css rules that depends on node (using the nid, I will use a nid of 34 and add rules for the various elements using the type, something like
You can of course use both $node->type and $node->nid.
If you want structural changes as well (different HTML) you can copy node.tpl.php to node-type.tpl.php (ex: node-page.tpl.php). You can read more about this at: http://drupal.org/node/17565