Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By rujikin on
I need to have a CSS class applied to certain content types. Some content types need the CSS class applied to them and other content types do not need it applied to them. Is there a way to specify this?
Comments
Hi most themes provide a
Hi
most themes provide a class according to the content type to the body.
so using this class you can give css to any element such that it is always according to content type
I love Drupal & working since 7.5+ years now in Drupal.
as a specific example, this
as a specific example, this page on drupal.org contains
so you can add css like
to pinkify all forum content type content.
The node level may not be useful enough for you, but other themes sometimes put the node type class into the body tag, so you may be able to use css chaining like
.dan. is the New Zealand Drupal Developer working on Government Web Standards
Perfect
thats perfect...
I love Drupal & working since 7.5+ years now in Drupal.
I am making a custom theme.
I am making a custom theme. No pre-made themes were quite what I wanted.
class="node-type-article"
Would this be correct? I just want to know how to associate it right now.
In case you can't see the
In case you can't see the node type in your theme, open node.tpl.php file from your theme's templates folder and add the following to where you have classes added to the most top level div.
print $node->type;
For example,
<div class=node-wrapper">
can be replaced with:
<div class=node-wrapper <?php print $node->type; ?>">
What's new and changing in PHP 8
Thanks! I found out the names
Thanks! I found out the names of those classes. Time to format them :D
node-amendment-headers