📘 公式リファレンス🔧 リファレンス/フィルター初級
link_to_vendor フィルター(ベンダーコレクションへのリンク生成)
商品ベンダー名を指定すると、そのベンダー配下の商品一覧を表示するコレクションページへのリンク(HTML `<a>` タグ)を生成するフィルター。
用途
商品詳細ページやコレクションページで、商品のベンダー名をクリッカブルなリンクにして、同じベンダーの全商品一覧ページへ遷移させたいとき。
設置場所
product.liquid や collection.liquid 内で `{{ product.vendor | link_to_vendor }}` または `{{ vendor_name | link_to_vendor }}` の形で使う。HTML 属性を追加する場合は `{{ product.vendor | link_to_vendor: class: 'vendor-link' }}` のように指定する。
注意点
フィルターは HTML `<a>` タグをそのまま文字列として返すため、タグのエスケープが必要な場合は Liquid で制御できない。ベンダー名が Shopify 管理画面で正確に登録されていることが前提で、未登録やスペルミスがあるとリンクが機能しない。class や id などの HTML 属性を追加する場合は attribute: value の形式で記述する。
仕様
48 行 / json{
"category": "collection",
"deprecated": false,
"deprecation_reason": "",
"description": "",
"parameters": [
{
"description": "attribute [string] [HTML attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes) for the link, passed as `attribute: value`.",
"name": "HTML",
"positional": true,
"required": false,
"types": []
}
],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"examples": [
{
"name": "",
"description": "",
"syntax": "",
"path": "/",
"raw_liquid": "{{ \"Polina's Potent Potions\" | link_to_vendor }}",
"parameter": false,
"display_type": "text",
"show_data_tab": true
},
{
"name": "HTML attributes",
"description": "You can specify [HTML attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attributes) by including a parameter that matches the attribute name, and the desired value.\n",
"syntax": "string | link_to_vendor: attribute: string",
"path": "/",
"raw_liquid": "{{ \"Polina's Potent Potions\" | link_to_vendor: class: 'link-class' }}",
"parameter": true,
"display_type": "text",
"show_data_tab": true
}
],
"summary": "Generates an HTML `<a>` tag with an `href` attribute linking to a [collection page](https://shopify.dev/docs/storefronts/themes/architecture/templates/collection) that lists all products of a given\nproduct vendor.",
"syntax": "string | link_to_vendor",
"name": "link_to_vendor"
}出典・ライセンス
- Repository:
- https://github.com/Shopify/theme-liquid-docs
- License:
- MIT
このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。
関連項目
📘 公式リファレンス🔧 リファレンス/フィルター初級
avatar フィルター(顧客アバター画像HTML生成)
顧客アバターが存在する場合、それを表示する HTML タグを生成するフィルター。customer オブジェクトに対して使用する。
📁 theme-liquid-docs·MIT·19 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
default_errors フィルター(フォーム送信エラーを日本語化)
form.errors の各エラーコードに対応する既定のエラーメッセージを自動生成するフィルター。フォーム送信時の入力値不正や必須項目空白などのエラーを言語別に出力する。
📁 theme-liquid-docs·MIT·19 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
date フィルター(日付を指定形式でフォーマット)
日付値を指定されたフォーマット文字列に従って整形する。フォーマット文字列が空の場合は元の値がそのまま返される。入力が日付に変換できない場合も元の値が返される。
📁 theme-liquid-docs·MIT·19 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
payment_terms フィルター(Shop Pay分割払いバナーを生成)
product フォームまたは cart フォームに対して使用し、Shop Pay の分割払いオプションを表示するための HTML を生成するフィルター。顧客が購入時に分割払いプランを選択できるようにする。
📁 theme-liquid-docs·MIT·19 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
abs フィルター(数値の絶対値を取得)
負の数を正の数に変換する。数値の絶対値(ゼロからの距離)を返すフィルター。
📁 theme-liquid-docs·MIT·30 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
append フィルター(文字列の末尾に追加)
文字列の末尾に別の文字列を連結するフィルター。URL パスの結合やテキストの接尾辞追加に使う。
📁 theme-liquid-docs·MIT·30 行