LoginSignup
1
0

More than 1 year has passed since last update.

カスタムモジュールの値をテンプレートで使用する

Last updated at Posted at 2021-06-14

モジュール
選択のフィールドを作成しておく

module.choice_comment

モジュールIDを確認

{% module "module_100000" path="/xxx/modules/setting", label="setting" %}

テンプレートファイルでモジュール名を指定してデータを参照
export_to_template_context=True

挙動
レンダリングされるのではなく、テンプレートのコンテキストにエクスポートされる?

{% module "module_100000" path="/xxx/modules/setting", label="setting", export_to_template_context=True %}
{% if widget_data.module_100000.choice_comment == 1 %}
  {% global_partial path='./partials/comment.html' %}
{% else %}
  その他の処理
{% endif %}

モジュールの名前でも利用可能

{% module "my_colors" path="/xxx/modules/my_colors", label="my_colors" %}
{{ widget_data.my_colors.body.color_1 }}

すでにページにレンダリングされているモジュールまたはタグからパラメータを取得する場合は、dict内でモジュールにアクセスできます。
しかしデフォルト値は取得できない?

// HubL
{{ content.widgets.my_colors.body.color_1 }}
{{ content.widgets.my_colors.body.color_2 }}
1
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
1
0