0

Is there an easy way to get node's view mode from entity.view?

function classier_preprocess_views_view(&$vars) {
    $vars['rows'][0]['#rows'][0]['#view_mode'];
}
1

If you're trying to get the view mode of a node you probably want to use a different hook.

function classier_preprocess_node(&$vars) {
    $view_mode = $vars['view_mode'];
}

Should do the trick.

  • Yes, it is a good solution, but i need get view mode form view – dirkgntly Dec 5 '17 at 6:01

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.