CMS Development

BillOddie
Member

Dynamic fields inside custom module

I have written some hubl that creates a choice field populated from hubDB. When this is placed in the 'Additional <head> markup' section of the template, the choice field appears in left handside 'Edit modules' section of content editor.

 

I need a custom module that contains multiple similar dynamic choice fields fed from hubdb and a blog, and to appear on the left handside in the content editor, under the name of the custom module it has been declared in.

 

When I move the dynamic choice field code to inside a custom module, it no longer appears anywhere in the content editor.

 

Here is the code for the dynamic choice field...

 

{% set currentList = [] %}
{% for row in hubdb_table_rows(1034058, "orderBy=random()") %}
{% set items2 = currentList.append(row.name|striptags) %}
{% endfor %}
{% set currentString = currentList|join(',') %}

{% choice "test" label='Test', value='test0', choices='{{ currentString }}' export_to_template_context=true %}

0 Upvotes
1 Reply 1
BillOddie
Member

Dynamic fields inside custom module

I still haven't managed to solve this problem, but for future reference, I found this forum post which is similar and suggests maybe it can't be done with custom modules, but maybe possible in coded files. Which sadly is no good for my case...

 

https://community.hubspot.com/t5/CMS-Development/Adding-coded-HubL-fields-to-v2-custom-module/td-p/1...

 

0 Upvotes