1

Having looked at other answers I'm pretty sure I've got this correct but it's still not working for me. I've stripped the code down to make it easier to read.

Error i'm getting is "Impossible to access an attribute ("packageName") on a string variable ("40")." This error repeats for packageTitle, packageShortIntro etc if I delete the packageName line etc..

All other fields, 'block.body', 'block.subTitle' are coming through fine.

Also please note there is also a Table field within the SuperTable.

{% for block in entry.pageContent %}
    {% switch block.type %}

        {% case 'bodyText' %}
            {{ block.body }}

        {% case 'packages' %}
            <!-- Supertable -->
            {% for row in block.package %}
                {{ row.packageName }}
                {{ row.packageTitle }}
                {{ row.packageShortIntro }}

                {% for items in row.itemsAvailable %}
                    {{ items.item }}
                    {{ items.isAvailable }}
                {% endfor %}

                {{ row.packageCost }}
            {% endfor %}
            <!-- End Supertable -->

        {% case 'subTitle' %}
            {{ block.subTitle }}

    {% endswitch %}
{% endfor %}

Many thanks for looking and any advice you can offer.

  • You normally need a .first() added somewhere when you get that warning I believe. However, I'd recommend commenting out all of the individual field lines in your supertable code, and going line by line to find the issue. – mention79 Oct 13 '17 at 9:44
  • Hi, thanks but I tried .first() and also commenting out code. – Martin Oct 13 '17 at 10:48
0

Your Super Table field is probably configured as a static field.

Have a look at the documentation for how to access subfields in this case: https://verbb.io/craft-plugins/super-table/docs/guides/templating-examples#static-super-table-field

So instead of the for-loop you’d have sth. like this: {{ block.package.packageName }}

| improve this answer | |
  • Brilliant! That's done it - phew :/ – Martin Oct 13 '17 at 15:34

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.