CMS Development

Olon
メンバー

Accessing parameters in custom module

解決

Hello,

in the docs, it says we can add custom parameters to modules. However the way to access them from inside the module is not specified. Heres my code:

 

{% module "module_152889614697214" module_id="3085289" label='Test', myParam='hello' %}

I've tried module.myParam with no luck.

 

Thanks

0 いいね!
1件の承認済みベストアンサー
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Accessing parameters in custom module

解決

The parameter cannot be arbitrary. You need to create the field in the custom module builder and then when you call it with the HUBL code in your template, that parameter name needs to match the parameter name inside the module.

 

Example:

In the dropdown in the custom module builder, you would choose text_field with a name of my_text_fied, now, you can pass a parameter that matches that name

{% module "module_152889614697214" module_id="3085289" label='Test', my_text_field='hello' %}

Then, inside of your module, all you have to do is 

{{module.my_text_field}}

tim@belch.io

元の投稿で解決策を見る

0 いいね!
1件の返信
tjoyce
解決策
名誉エキスパート | Elite Partner
名誉エキスパート | Elite Partner

Accessing parameters in custom module

解決

The parameter cannot be arbitrary. You need to create the field in the custom module builder and then when you call it with the HUBL code in your template, that parameter name needs to match the parameter name inside the module.

 

Example:

In the dropdown in the custom module builder, you would choose text_field with a name of my_text_fied, now, you can pass a parameter that matches that name

{% module "module_152889614697214" module_id="3085289" label='Test', my_text_field='hello' %}

Then, inside of your module, all you have to do is 

{{module.my_text_field}}

tim@belch.io

0 いいね!