2019/5/1

Craft CMS で非推奨のエラーをなくす

管理画面をみてると非推奨エラーが出てるのでちょこちょこ修正。

feed用の取得のところ

{% for entry in craft.entries.section(‘article’).limit(30) %} ↓↓↓ {% set entries = craft.entries.section(‘article’).limit(30) %} {% for entry in entries.all() %}

タグのループのところ

{% for tag in tags %} ↓↓↓ {% for tag in tags.all() %}

参考

templating - How do I clear deprecation errors for looping through element queries? - Craft CMS Stack Exchange
https://craftcms.stackexchange…

ドキュメントみるとlimitでとったあとにall()した方が良いんだろうな。

{% set entries = craft.entries() .section(‘news’) .limit(10) .all() %}

エレメントクエリについて | Craft 3 ドキュメント
https://docs.craftcms.com/v3/j…

なるほどなるほどー。

検索結果のところ

{% set entries = craft.entries.search(query).order(‘score’) %} ↓↓↓ {% set entries = craft.entries.search(query).orderBy(‘score’) %}

Entry Queries | Craft 3 Documentation
https://docs.craftcms.com/v3/d…