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:
- Helpful node methods in Drupal 8
- how to add bootstrap readmore button to teaser in drupal 8
- Drupal: Creating a Computed Entity Field
- how to Programmatically update an entity reference field in Drupal 8 & 9
- How to add class to content field link in Drupal 8 / 9
1,191