TransWikia.com

Explanation of Deprecation Warnings

Craft CMS Asked by P. Colin Manikoth on December 8, 2020

Why is this depreciated? Is there an example of the preferred method?

Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them.

Thanks.

One Answer

It means you've got a loop on an element query somewhere in your templates. For example:

{% for entry in craft.entries.section('mySection') %}
    {{ entry.title }}
{% endfor %}

You should update it to use .all() like so:

{% for entry in craft.entries.section('mySection').all() %}
    {{ entry.title }}
{% endfor %}

Answered by Brad Bell on December 8, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP