How to get view mode of node in Drupal 8 & 9

4
(1)

Example How to get view mode of node in Drupal 8 & 9:

function THEMENAME_preprocess_node(&$vars) {

  if(($node->getType() == 'article') && ($vars['view_mode'] == 'teaser')) {

      // TODO
  }
}

Similar Posts:

607

How useful was this post?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

Scroll to Top