Adding a clearfix class to hook_node_view Ok, so what I want to do is to add a class of clearfix whenever Drupal outputs a node view with inline links.

I've been looking around and I figured hook_node_view() is what I need to alter.

Looking in node.module I find the following code:

$node-&gt;content['links'] = array(
    '#theme' =&gt; 'links__node',
    '#pre_render' =&gt; array('drupal_pre_render_links'),
    '#attributes' =&gt; array('class' =&gt; array('links', 'inline')),
);

$node-&gt;content['links']['node'] = array(
    '#theme' =&gt; 'links__node__node',
    '#links' =&gt; $links,
    '#attributes' =&gt; array('class' =&gt; array('links', 'inline')),
);


So I guessed I somehow have to add a third value to this array trough my template.php file, but none of the gazillion ways I tried worked.
You can do this in a hook_preprocess_node() function in your theme's template.php file:

function MYTHEME_preprocess_node(&amp;$vars) {
  if (isset($vars['content']['links'])) {
    $vars['content']['links']['#attributes']['class'][] = 'clearfix';
  }
}


Remember to clear Drupal's caches once you've added the function so the system picks it up.