2

I've got a matrix with a Block type called textBlocks which Craft seems to be having trouble seeing.

The error is:

Craft\MatrixBlockModel and its behaviors do not have a method or closure named "textBlocks".

My template code is:

{% for block in entry.clientsContent %}

 {% switch block.type %}

{% case "text" %}


 <div class="small-{{ block.columns }}">
  <h3>{{ block.blockTitle }}</h3>
  <p>{{ block.blockContent }}</p>
 </div>


{% case "images" %}
 <ul class="small-block-grid-{{ block.blockGrid }}">
  {% for asset in block.images %}
   <li>
    <img src="{{ asset.getUrl() }}" alt=""/>
   </li>
  {% endfor %}
 </ul>

 {% case "textBlocks" %}
 <ul class="small-block-grid-{{ textBlocks.blockGridNumber }}">
  {% for row in block.textBlocks %}
   <li><h5>{{ row.title }}</h5> <p>{{ row.content }}</p></li>
  {% endfor %}
 </ul>
{% endswitch %}

{% endfor %}

Am i getting this right here? When you do switch block.type is block.type the Block Type name?

See pic for my Matrix setup: enter image description here

1
  • Ah no, i have just made a code error like a fool!
    – John
    Commented Feb 1, 2015 at 17:48

1 Answer 1

3

I think you already spotted it.

Change:

<ul class="small-block-grid-{{ textBlocks.blockGridNumber }}">

To:

<ul class="small-block-grid-{{ block.blockGridNumber }}">
1
  • Yeah i'm an idiot.
    – John
    Commented Feb 1, 2015 at 19:34

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.