1

What could be the reason for this error when I’m targeting a global field?:

Impossible to access an attribute ("footer") on a boolean variable ("").

I created a global set Footer with a matrix field also named Footer, I'm trying to get its content via:

{% for block in footer.footer %}
  {% if block.type == "column" %}
    <div>
      <h4>{{ block.headline }}</h4>
      <div>{{ block.columnContent }}</div>
    </div>
  {% endif %}
{% endfor %}
4
  • We need more of your code in order to help you. How do you fetch the global set, what are you doing with it after your loop Commented Jan 7, 2018 at 17:26
  • @RobinSchambach Thanks for the advice, I added some lines. Do that help?
    – Malte
    Commented Jan 7, 2018 at 17:54
  • 2
    Your code is actually correct. I created the set footer with the matrix field footer and the block column with the fields headline and columnContent and copied your code as it is with {% set footer = craft.globals.getSetByHandle('footer')%} and it works. You error must be related to your fields/your field handles or the field types. Since we don't know your layout we can't really help you Commented Jan 7, 2018 at 18:07
  • Could you show us how you fetch your global set? Because of your error message I get the feeling you didn't fetch the set Commented Jan 8, 2018 at 16:11

2 Answers 2

2

I do not see anything obviously wrong with your code, but something that has caught me out many times is a misspelling of field names, so be sure your twig code matches your field names exactly. One thing that is a bit odd is the error message references "footerContent", but that does not appear in your code.

2
  • Ok, thanks.. that's because I've tested changing the field handle to ensure that's the right name.. (I've corrected it)
    – Malte
    Commented Jan 8, 2018 at 15:57
  • I just put your code on a test page and it seems to work fine.
    – Roi Agneta
    Commented Jan 8, 2018 at 21:37
1

I've finally found this shame fault. I created a variable named footer to control the layout – that's not that good in combination with a field named footer.

Sorry for stealing your time...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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