LoginSignup
0
0

More than 1 year has passed since last update.

【CraftCMS】MatrixフィールドでSuperTableを使う時の注意点

Posted at

経緯

matrixのブロックで定義したSuperTableフィールドの画像フィールドのパスの定義として

/data/img/記事セクション/記事ID/

としたかったのでアセットアロケーションは

[データパス] img/{owner.section.handle}/{owner.id}

と設定したのだが記事登録してみるとこんなエラー

The Entry Image field’s Upload Location setting has an invalid subpath (“{owner.section.handle}”).

どこにアップすんねんエラーです。

ownerとは誰なのか

matrixフィールドに於けるownerとは、そのフィールドが紐付けられたエントリ を指してます。

SuperTable in matrixの場合

Entry 
 ┗ Matrix
   ┗ SuperTable

こういうことになりますので〜

Entryのsectionを拾いたい場合は

[データパス] img/{owner.owner.section.handle}/{owner.owner.id}

SuperTableから見た所有者(Matrix)の所有者、つまりEntryということになるっぽいです。

owner.idはエラーにならなかったけど、これはmatrixフィールドのIDを取得していたからなので
地味に設定ミスだったということが判明しました。

おわり。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0