section オブジェクト
セクションの ID、設定値、ブロック配列、ページ内の位置情報(index)を提供するオブジェクト。テンプレートやセクショングループ内でセクションの動的な挙動をコントロールする。
仕様
117 行 / json{
"access": {
"global": false,
"parents": [],
"template": []
},
"deprecated": false,
"deprecation_reason": "",
"description": "> Tip:\n> To learn about sections and using them in a theme, refer to [Sections](/themes/architecture/sections).",
"properties": [
{
"deprecated": false,
"deprecation_reason": "",
"description": "The ID for sections included through [JSON templates](/themes/architecture/templates/json-templates) are dynamically\ngenerated by Shopify.\n\nThe ID for static sections is the section file name without the `.liquid` extension. For example, a `header.liquid`\nsection has an ID of `header`.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The ID of the section.",
"name": "id"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "To learn about how to access settings, refer to [Access settings](/themes/architecture/settings#access-settings).",
"examples": [],
"return_type": [
{
"type": "untyped",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The [settings](https://shopify.dev/themes/architecture/sections/section-schema#settings) of the section.",
"name": "settings"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "Use this property to adjust section behavior based on its position within its location ([template](/docs/themes/architecture/templates), [section group](/docs/themes/architecture/section-groups)) and on the page. The `index` starts at 1 within each location.\n\nAn example use case is for programmatically setting `loading=\"lazy\"` for images below the fold based on an index higher than, for example, 3. Note that this is now the default behavior for the [`image_tag` filter](/docs/api/liquid/filters#image_tag).\n\nOnly use this for non-display use cases like web performance. Because of various limitations, the `index` property returns `nil` in the following contexts:\n\n- When rendered as a [static section](/docs/themes/architecture/sections#statically-render-a-section)\n- While rendering in the online store editor\n- When using the [Section Rendering API](/docs/api/section-rendering)",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The 1-based index of the current section within its location.",
"name": "index"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "This is the same as the `index` property except that the index starts at 0 instead of 1.",
"examples": [],
"return_type": [
{
"type": "number",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The 0-based index of the current section within its location.",
"name": "index0"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "Sections can have one of four different location types. For sections rendered within a [template](/docs/themes/architecture/templates), the location will be `template`. For sections rendered within a [section group](/docs/themes/architecture/section-groups), the location will be the section group type, e.g., `header`, `footer`, `custom.<type>`. Sections [rendered statically](/docs/themes/architecture/sections#statically-render-a-section) will be `static`. Finally, if you're still using `content_for_index`, then the value will be `content_for_index`.",
"examples": [],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"summary": "The scope or context of the section (template, section group, or global).",
"name": "location"
},
{
"deprecated": false,
"deprecation_reason": "",
"description": "",
"examples": [],
"return_type": [
{
"type": "array",
"name": "",
"description": "",
"array_value": "block"
}
],
"summary": "The blocks of the section.",
"name": "blocks"
}
],
"summary": "The properties and settings of a section.",
"name": "section",
"examples": [],
"json_data": {
"path": "",
"handle": "",
"data_from_file": "{\"blocks\":[],\"id\":\"template--14453298921537__cart-items\",\"settings\":{}}"
},
"return_type": []
}出典・ライセンス
- Repository:
- https://github.com/Shopify/theme-liquid-docs
- License:
- MIT
このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。
関連項目
content_for_header オブジェクト
Shopify が必要とするスクリプト(分析・チェックアウト・言語設定など)をすべて動的に出力するオブジェクト。theme.liquid の <head> タグ内に埋め込む必須要素。
metaobjects オブジェクト
ストア全体のメタオブジェクト定義にアクセスするグローバルオブジェクト。個別のメタオブジェクトはタイプとハンドルで参照でき、メタオブジェクト定義のエントリをループで反復処理できる。
additional_checkout_buttons オブジェクト
PayPal Express Checkout など、オフサイト決済に対応した外部決済プロバイダーがストアに設定されているかを真偽値で返す。`content_for_additional_checkout_buttons` と組み合わせて、該当するチェックアウトボタンを条件付きで表示する。
canonical_url オブジェクト
現在のページの正規 URL を取得するオブジェクト。Google などの検索エンジンに対してどのページ版が正規であるかを指定するために使用する。
content_for_index オブジェクト
ホームページに表示するセクションの内容を動的に返すオブジェクト。Liquid インデックステンプレートで必ず使用する。
content_for_additional_checkout_buttons オブジェクト
PayPal、Apple Pay、Google Pay など複数の決済プロバイダが有効になっているとき、その決済ボタンを HTML として出力するオブジェクト。`additional_checkout_buttons` で有無を判定したうえで、このオブジェクトで実際のボタンを表示する。