1

I need the to find the block view name so I can add it to the if statement in hook_preprocess_views_view_field in Drupal 8. How would I do this? When I use kint($variables['field']) to find the variables Drupal explodes so I don't even know if the variables exists

/**
 * Implements hook_preprocess_views_view_field()
 *
 */
function mytheme_preprocess_views_view_field(&$variables) {
    //-- I need the to find the view name
    //-- so I can add it to the if statement
    if ($variables['field']->field == 'nid') {
    }
}
4

Try the following

//gives you views current display - "block_1" or "page_1"
$variables['view']->current_display;

//gives you views id - "recent"
$variables['view']->id();
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.