Score:0

Print the "title" variable in unformatted views twig

gb flag

I am trying to do something like this in views-view-unformatted-something.html.twig:

<h3 class="{{ title }}">{{ title }}</h3>

...but something goes wrong. Nothing is injected into the class.

No Sssweat avatar
ua flag
`Nothing is injected into the class` likely because `{{ title }}` has some markup like `<div class="view-title">My Cool Title</div>` and it's not just the raw value of `My Cool Title`.
Score:0
cn flag

You can try using .addClass -> https://www.drupal.org/docs/8/theming-drupal-8/using-attributes-in-templates

  <h3 {{title_attributes.addClass(title)}}>{{ title }}</h3>

Additionally, if you are attempting to access the title of the page, which I assume you are, you may have better luck overriding 'page-title.html.twig' instead, since that is actually what renders the title element (your results may vary).

enter image description here

worked for me

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.