CMS Development

jcpux
参加者

Is there a mutli-select widget I can use with export_to_template_context??

I'm using the following code in my page template <head> to generate a 'choice' select-box widget from the row NAMEs in my hubDB table, and exporting it to template_context

 

{% set array = [] %}
{% set rows = hubdb_table_rows(XXXXXXX) %}
 {% for row in rows %}
  {% set items = array.append(row.name) %}
 {% endfor %}
{% set stringArray = array|join(', ') %}
{% choice "case_study" label='Choose the correct case study', choices='{{stringArray}}', no_wrapper=True, export_to_template_context=True %}
{% set choiceValue = widget_data.case_study.value|replace(' ', '%20') %}
{% set finalChoiceValue = "name=" ~ choiceValue %}

and then, in the module, this looks up that row using the finalChoiceValue value

 

{% for row in hubdb_table_rows(XXXXXX, finalChoiceValue) %}
  <img src="{{ row.logo_sized.url }}" alt="{{ row.name }}" />
{% endfor %}

What I need is to do this same thing but to be able to select multiple rows, so like an array of checkboxes perhaps, instead of the "choice" select-box. Is this possible? 

 

 

 

0 いいね!
3件の返信
John
トップ投稿者 | Platinum Partner
トップ投稿者 | Platinum Partner

Is there a mutli-select widget I can use with export_to_template_context??

Great minds think alike. A multiselect field is really needed in custom modules. Here is my idea/suggestion for it in the ideas forum.

 

Please upvote it and get your friends to as well haha



I like kudos almost as much as cake – a close second.

Jake_Lett
ガイド役 | Solutions Partner
ガイド役 | Solutions Partner

Is there a mutli-select widget I can use with export_to_template_context??

{% set choices = choicesArray|split(', ') %}

One thing you could do is experiment with is using a text field supported with good help text and documentation. In your help text explain how enter choices seperated by a comma. You can then use the field data and create your array off that.

 

You could also create a page with a simple multi select with a textarea box that autopopulates what they need to copy and paste in the module. Then link to this in the help text. This is a polyfill solution until HubSpot adds this field.


Jacob Lett

Freelance HubSpot CMS Developer & Web Designer


bootstrapcreative-horizontal-trim.png

Located in Michigan, USA

View Web Design & Development Portfolio


sharonlicari
コミュニティーマネージャー
コミュニティーマネージャー

Is there a mutli-select widget I can use with export_to_template_context??

Hey @jcpux 

 

Thank you for sharing this information, I'll tag a few experts that can share their thoughts with you.

 

Hey @John @Jake_Lett @SandyG1 what would you advise to @jcpux?

 

Thanks

Sharon


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !