0

I’m upgrading my Craft2 blog to Craft3 at https://brill.blog. I’ve got a loop to display text, images, and block quotes from a Matrix field, that follows this pattern:

{% for block in entry.matrixContent %}

    {% if block.type == "imageBlock" %}
        <img src="{{ image.getUrl(transform) }}" alt="{{ image.title }}" />

    {% elseif block.type == "textBlock" %}
        {{ block.text | smartypants | replace({'&nbsp;' : ' '}) | raw }}

    {% endif %}

{% endfor %}

The actual code has lots more 'elseif's for image rows, block quotes etc. This all works fine in Craft2.

For Craft3, I’ve added .all() to the first line. But the result is that the only image blocks get rendered correctly, and everything else is missing.

Is there anything obvious I should be looking for?

I’d be happy to post much more code, if anyone here is willing to look through it.

Thanks in anticipation.

  • Be sure to have devMode switched on and it'll show you any error messages – James Smith Nov 24 '19 at 11:29
  • It's definitely in dev mode. Craft3 version has same code as Craft2, but only displays the imageBlocks, omits everything else. Very weird! – Brian Liddell Nov 26 '19 at 15:16
  • Have you tried it without changing the code? It'll still run - though it will have some deprecation message about using .all() instead of "old" looping, but if the problem lies therein, then should be the easiest way to find out. – Campiotti Nov 29 '19 at 13:06

Your Answer

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

Browse other questions tagged or ask your own question.