I successfully place block with twig_teak module programmatically in my twig file. Unfortunately in order for this to work, it needs a region in the UI. How should I hide it from its original region? I'm placing it with code, so I don't want it showing up in any region, and disabling it removes it everywhere. Styling the unwanted one out on the front end is hopefully not the recommended solution here.
1 Answer
Block configuration entities need a region, but not blocks in general. Twig Tweak can generate the block config on the fly and doesn't need them to be stored in the database:
{{ drupal_block('plugin_id', {label: 'Example'|t, some_setting: 'example', setting_array: {value: value}}) }}
If you don't know the plugin and the settings, configure a block in UI temporarily and export the YAML file (/admin/config/development/configuration/single/export). You find both near the end of the file.
https://git.drupalcode.org/project/twig_tweak/-/blob/3.x/docs/blocks.md#block-plugin