Score:0

Update viewport value

gr flag

maybe it's a stupid question but I couldn't find any appropriate answer to this question. I have a website with Drupal 9.4.8 I need to change the default viewport meta, but I couldn't find a way to do it. I have the Metatag module (which I use to configure my open graph tags) but I can't find any field where I could update the viewport value. I also read that I need to add this function in a .theme file

function MY_THEME_page_attachments_alter(&$page) {
  $viewport = array(
    '#type' => 'html_tag',
    '#tag' => 'meta',
    '#attributes' => array(
      'name' => 'viewport',
      'content' => 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no',
    ),
  );
  $page['#attached']['html_head'][] = [$viewport, 'viewport'];
}

But that doesn't seem to work either. The content is added as plain text (and not added at all if I simply add <?php ?> tags around the function).

It's probably something really obvious since I can't find any topics mentioning it but I admit I'm a bit lost actually. Any help?

Thank you.

ru flag
This should be possible in Metatag's sub-module "Mobile & UI Adjustments", but you need to enable the sub-module manually.
Fabrice Lefloch avatar
gr flag
Indeed I forgot there was some extra modules with Metatags. Thanks for pointing this out.
I sit in a Tesla and translated this thread with Ai:

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.