📘 公式リファレンス📦 リファレンス/オブジェクト中級
metaobject オブジェクト
メタオブジェクト定義に基づいて作成された個別のメタオブジェクトエントリ。メタオブジェクト定義で定義されたフィールドの値セットを保有する。
用途
ブランドストーリー、FAQ、推薦文、ウィジェットなど、Shopify 管理画面で構造化して定義したカスタムデータをテンプレートやセクション内で参照・表示する。
設置場所
Liquid 内で `{{ metaobjects.型名.ハンドル }}` または `{{ metaobjects['型名']['ハンドル'] }}` の形で個別メタオブジェクトを参照し、`{{ metaobject.フィールドキー.value }}` でフィールド値を取得する。メタオブジェクトテンプレート内では `{{ metaobject }}` で現在のメタオブジェクトに直接アクセスできる。
注意点
publishable 機能が有効な場合、ステータスが `active` のメタオブジェクトのみアクセス可能で、`draft` ステータスは `nil` を返す。メタオブジェクト型ごとのハンドルと各フィールドキーは Shopify 管理画面で定義した値に対応し、存在しないキーにアクセスするとエラーになるため、事前に定義を確認する必要がある。
仕様
65 行 / json{
"access": {
"global": false,
"parents": [
{
"object": "metaobjects",
"property": ""
}
],
"template": [
"metaobject"
]
},
"deprecated": false,
"deprecation_reason": "",
"description": "",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "metaobject_system",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "Basic information about the metaobject. These properties are grouped under the `system` object to avoid collisions between system property names and user-defined metaobject fields.",
"name": "system"
}
],
"summary": "A metaobject entry, which includes the values for a set of [fields](/docs/api/liquid/objects#metafield).\nThe set is defined by the parent [`metaobject_definition`](/docs/api/liquid/objects#metaobject_definition).",
"name": "metaobject",
"examples": [
{
"name": "Access metaobjects individually",
"description": "The access path for a metaobject consists of two layers:\n\n- type - The type of the parent metaobject definition.\n- handle - The unique [handle](/docs/api/liquid/basics#handles) of the metaobject.\n\nGiven this, you can access a metaobject with the following syntax:\n\n```liquid\n{{ metaobjects.type.handle }}\n```\n\nYou can also use square bracket notation:\n\n```liquid\n{{ metaobjects['type']['handle'] }}\n```\n\nA metaobjects's field values can be accessed using the key of the desired field:\n\n```liquid\n{{ metaobjects.testimonials.homepage.title }}\n{{ metaobjects['highlights']['washable'].image.value }}\n```\n\n> Note:\n> When the [`publishable` capability](/apps/data-extensions/metaobjects/capabilities) is enabled, a metaobject can only be accessed if its status is `active`. If its status is `draft`, then the return value is `nil`.\n",
"syntax": "",
"path": "",
"raw_liquid": "",
"parameter": false,
"display_type": "text",
"show_data_tab": false
},
{
"name": "Usage in metaobject templates",
"description": "Within a metaobject template, the `metaobject` Liquid object represents the metaobject drop being rendered by the template. You can access it directly as `{{ metaobject }}`.\n\nHere's a basic example of accessing a field within the associated metaobject template:\n```liquid\n{{ metaobject.title.value }}\n```\n\nIn this example, replace `title` with the key of the field you want to access. This will output the value of that field for the current metaobject.\n",
"syntax": "",
"path": "",
"raw_liquid": "",
"parameter": false,
"display_type": "text",
"show_data_tab": false
}
],
"json_data": {
"path": "",
"handle": "",
"data_from_file": ""
},
"return_type": []
}出典・ライセンス
- Repository:
- https://github.com/Shopify/theme-liquid-docs
- License:
- MIT
このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。
関連項目
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_header オブジェクト
Shopify が必要とするスクリプト(分析・チェックアウト・言語設定など)をすべて動的に出力するオブジェクト。theme.liquid の <head> タグ内に埋め込む必須要素。
📁 theme-liquid-docs·MIT·20 行
📘 公式リファレンス📦 リファレンス/オブジェクト中級
metaobjects オブジェクト
ストア全体のメタオブジェクト定義にアクセスするグローバルオブジェクト。個別のメタオブジェクトはタイプとハンドルで参照でき、メタオブジェクト定義のエントリをループで反復処理できる。
📁 theme-liquid-docs·MIT·20 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
additional_checkout_buttons オブジェクト
PayPal Express Checkout など、オフサイト決済に対応した外部決済プロバイダーがストアに設定されているかを真偽値で返す。`content_for_additional_checkout_buttons` と組み合わせて、該当するチェックアウトボタンを条件付きで表示する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
canonical_url オブジェクト
現在のページの正規 URL を取得するオブジェクト。Google などの検索エンジンに対してどのページ版が正規であるかを指定するために使用する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_index オブジェクト
ホームページに表示するセクションの内容を動的に返すオブジェクト。Liquid インデックステンプレートで必ず使用する。
📁 theme-liquid-docs·MIT·27 行
📘 公式リファレンス📦 リファレンス/オブジェクト初級
content_for_additional_checkout_buttons オブジェクト
PayPal、Apple Pay、Google Pay など複数の決済プロバイダが有効になっているとき、その決済ボタンを HTML として出力するオブジェクト。`additional_checkout_buttons` で有無を判定したうえで、このオブジェクトで実際のボタンを表示する。
📁 theme-liquid-docs·MIT·27 行