Add 'view-mode' class to nodes

Created on 21 May 2014, almost 11 years ago
Updated 16 May 2024, 11 months ago

Implementing custom view modes is great, but doing so means you can no longer tell what view mode a node is using just by looking at the CSS (like you can with the 'node-teaser' class). I therefore propose adding a 'view-mode' class to nodes (somehow).

I did this myself by overriding template_preprocess_node() in my theme's template.php file:

function THEME_preprocess_node(&$variables) {
  // Add view-mode class to nodes
  $variables['classes_array'][] = drupal_html_class('entity-view-mode--' . $variables['view_mode']);
}

However you'd have to somehow do this in the module itself to include this by default...

Feature request
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024