Little snippet to get the current view mode:

function THEMENAME_preprocess_node(&$vars) { 
 if(($node->getType() == 'event') && ($vars['view_mode'] == 'teaser')) {
    // Go further here
  }
}

 

 

 

 

Saved you some valuable time?

 

Donate and get more free time-saving code on this website in the future.