templatetags Package¶
products_tags
Module¶
全てのCategory一覧を取り出します。
- Syntax:
- {% get_categories as <variable> %}
全てのPlatform一覧を取り出します。
- Syntax:
- {% get_platforms as <variable> %}
任意の<lookup>によりフィルタされた Product のクエリを取得し指定された <variable>に格納するテンプレートタグ
- Syntax:
- {% get_products as <variable> %} {% get_products <lookup> as <variable> %}
- Lookup: (Default: mixed)
- mixed: display_mode が featured/tiled な Product を返す normal: display_mode が normal な Product を返す featured: display_mode が featured な Product を返す tiled: display_mode が tiled な Product を返す
Examples
display_mode が featured/tiled な Product のクエリを取得し、最新 5件のみを描画
{% get_products as products %} {% for product in products|slice:”:5” %}
{{ product }}{% endfor %}
display_mode が normal な Product を取得
{% get_products ‘normal’ as normal_products %}
任意のカテゴリに所属するProductを返却します
- categories:
- CategoryのQuerySet
Example
{% load products_tag %} {% get_product_by_category <categories> as <variable> %}
任意のプロダクトの関連プロダクトを取り出します。 渡されたプロダクトと同じカテゴリに所属している物全てから、自身を抜いた QuerySetを返します
- Syntax:
- {% get_relative <product> as <variable> %}
プロダクト用のTwitterカードを埋め込むテンプレートタグ 通常はhead内に書く
- Syntax:
- {% render_twitter_card product %}
- Template:
products/components/twitter_card.htmlが使用される。 このテンプレートは以下のコンテキストを受け取れる
product: 描画対象のProductオブジェクト apps: Productの所属するURLReleaseのうち、iOSアプリ、Androidアプリのもののみが含まれたリスト
このような仕様になっているのは、appsがある場合のみTwitterカードのApp Cardを利用することが想定されているためである