Score:0

"block_name" not found

cn flag

I installed the Twig Tweak module.

{{ drupal_block('block_name') }}

doesn't work. In Drupal logs I get the error

The "block_name" was not found

"block_name" I get from the config url of the block config page

admin/structure/block/manage/block_name?destination=/de/admin/structure/block

Do I do anything wrong?

cn flag
Great! Thank you!
Score:3
in flag

You need to use:

{{ drupal_entity('block', 'MY_BLOCK_ID') }}

The Rendering blocks with Twig Tweak guide walks through the three common block types and how to render them.

Block plugins, i.e. custom blocks defined with an annotation

{{ drupal_block('MY_BLOCK_ID') }}

Block configuration entities, i.e. blocks configured at /admin/structure/block (what it looks like you're trying to do)

{{ drupal_entity('block', 'MY_BLOCK_ID') }}

Block content entities, i.e. blocks managed at /admin/structure/block/block-content

{{ drupal_entity('block_content', 'MY_BLOCK_ID') }}
Score:2
cn flag

You don't need to place the block in Block Layout. Twig Tweak creates a block instance on the fly.

Use the block plugin ID. You find the ID in the annotations of the plugin class. For example the core branding block:

* @Block(
 *   id = "system_branding_block",

If the block is derived from block content the UUID is added after a colon, for example: block_content:4124d2132-5ed1-4a12-add1-144e210da157

More info https://git.drupalcode.org/project/twig_tweak/-/blob/3.x/docs/blocks.md#block-plugin

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.