Score:0

Transform the view mode of a content type into the class of the body

cn flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.