In my taxonomy-term--NAME.html.twig I use a reference field to load a 'block_content'.

{% for item in term.field_blocks %}
  {% set uuid =  item.entity.uuid.value %}
  {{ drupal_block('block_content:' ~ uuid) }}
{% endfor %}

The block is rendered correctly but without the 'contextual links' (quick edit on front-end).

When I look into the twig_tweak module, I see you can add an array with configuration options.

public function drupalBlock($id, array $configuration = [], $wrapper = TRUE) {

    $configuration += ['label_display' => BlockPluginInterface::BLOCK_LABEL_VISIBLE];

    /** @var \Drupal\Core\Block\BlockPluginInterface $block_plugin */
    $block_plugin = \Drupal::service('plugin.manager.block')
      ->createInstance($id, $configuration);

Does anyone know how I can change the twig-rule to something like this:

{{ drupal_block('block_content:' ~ uuid, {show_contextual_links:true}) }}

I found this question, but that is not correct: Programatically render block with contextual links (in php)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.