Score:0

Custom html.html.twig for a display mode

iq flag

While using display suite in drupal 8.6.2 Is it possible to have a custom displaymode-html.html.twig that replaces the default html.html.twig?

So far I have tried enabling the view mode dev hints in themename.yml but it doesn't seem to be showing me anything for html.html.twig

Alireza Tabatabaeian avatar
cn flag
what is your propose of having a custom html.twig file? this file is not meant to be used for design proposes much, just placement of page , page bottom, page top and placeholders
byte me avatar
iq flag
The placement needs to vary, but only for certain display modes.
Alireza Tabatabaeian avatar
cn flag
You don't have any theming variables in this file , even you have no access to regions , so how placement might vary when you only have page top which must be before page, page and page button which should be placed after page?
Alireza Tabatabaeian avatar
cn flag
I think you should have use other theming files like page.html.twig not html.html.twig
byte me avatar
iq flag
Thanks! Is there any documentation that would cover this?
byte me avatar
iq flag
Also, js and css placeholders are in `html.html.twig` not sure how I'd be able to override them inside `page--viewmode.html.twig`
Alireza Tabatabaeian avatar
cn flag
theming files act as hierarchical in html.html.twig you place page variable, then in page.html.twig you place regions placement, regions are places that blocks are placed and ...
Alireza Tabatabaeian avatar
cn flag
https://www.drupal.org/docs/theming-drupal is the drupal reference for learning how to theme, there are many more tutorials available, I highly recommend www.Drupalize.me but it is not free
Score:0
de flag

I'm not used to Display Suite but I'd recommend you to have a look at hook_theme_suggestions_alter() in order to build your own twig template suggestions based on specific conditions that you can set using the $variables variable values.

byte me avatar
iq flag
Thanks. I tried this with the hook set to `html` but it just shows me a blank in view mode.
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.