0

I created a custom block named "Alert Bar" in the "navigation" region and I want to render it in my header file.

My header file currently has code like this to render the blocks -

{% if page.navigation or page.navigation_collapsible %}
  {% block navbar %}
    {% if no_head != 'true' %}
      {% include '@eventsns/components/navbar.html.twig' with incs %}
    {% endif %}
  {% endblock %}

Can I do something like {% block alertbar %} to display the alert bar block? The machine name says it is "alertbar" but I'm not sure if that's the correct variable since it does not render anything.

1
  • 1
    block in twig is not the same as block in drupal, if that's what you are thinking.
    – Kevin
    Jan 27, 2021 at 23:37

1 Answer 1

2
  1. block in twig are a "placedholder" to re-use text. They aren't drupal blocks
  2. The easiest way as far I know to print a block is to use twig tweak module. The could should be {{ drupal_entity('block', 'block_id', check_access=false) }}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.