なぜ、定義されている場合には、stRow.captionを参照するとエラーが発生するのはなぜですか?
エラーは次のとおりです。
Craft SuperTable_BlockModelとその動作にはメソッドがありません。
クロージャは「キャプション」と呼ばれます。
私は壊滅的に愚かなことをする必要があります。
{% if stRow.caption is defined %}
{% set caption = stRow.caption %} <<- This line causes the error
{% endif %}
null coelescing演算子または3項演算子を使用する場合と同じです。
{{ stRow.caption ?? "" }} <<- This causes the error
-- or --
{{ stRow.caption is defined ? stRow.caption : "" }} <<- This causes the error too!
それらの3つすべてがうまくいくはずです。
スーパーターゲット:1.0.4 クラフトCMS:2.6.2997
ベストアンサー
これは変わった小枝の動きです。 twitterのオブジェクト構文のためにstRow
[‘caption’]が定義されている場合はを実行する必要があります。
場合によっては、配列構文を使用しないとif defined文がtrueになることがあります