0

All blocks in the footer region use a CSS grid system. I want to add a <div> with CSS attributes to each (custom) block in the footer. The code I have will show the blocks in the footer, but will give an error. Changing {{ key }} to {{ key.content }} is not helping. I am using Drupal 8.6.8.

The code that I am using in the page.html.twig template is the following.

{% for key in page.footer %}
    <div class="col col-4">
        {{ key }}
    </div>
{% endfor %}

Using that code, I get this error message.

User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core\lib\Drupal\Core\Render\Element.php).

  • are you using the bootstrap theme ? try {% for key, val in page.footer %} {{ dump .. or knit val }} – Taggart Jensen Feb 19 at 2:56
0

Remove array keys starting with '#':

{% for key, block in page.footer if key|first != '#' %}
    <div class="col col-4">
        {{ block }}
    </div>
{% endfor %}

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.