Add CSS-class to current node in module logic In a custom module, I add some logic to the node rendering. Based on this, I would also like to add some appropriate CSS-classes to the current node.
The below code expresses  what I would like to do, but don't know how to do.

$node-&gt;classes[] = $class;


Because I already have the appropriate logic in my module, it seems to me like the adding of classes should be handled in the same place. I could do this in a template instead, but that would require me to duplicate all the logic.
Would hook_preprocess_node help you for this?

Example:

function mymodule_preprocess_node(&amp;$variables) {
  $variables['classes_array'][] = 'blah';
}


The variables array contains all information about the ndoe as well, so you can run logic to dictate which classes should be added to which node types/IDs etc.

If you run dpm (with the Devel module enabled) then you can print everything in that array that you can alter/add to.

I agree that $node-&gt;classes would be a really useful addition though.