0

I want to add the view mode of my content type as a class to body and I use Display Suite so $node['view_mode'] is not available.

In MYTHEME_preprocess_html(&$variables), I injected the service \Drupal::service('entity_display.repository') and \Drupal::service('entity_display.repository')->getViewModes('node') returns the list of all view modes for this content type.

How can I find out what the view mode of the active node is, in order to transform it into a class?

Thanks in advance for any help you can provide.

Your Answer

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

Browse other questions tagged or ask your own question.