I currently working on a custom module for landing page templates, which implementes window modal. So that I can click on a button, a pop-up window appears where I can see content. Then I can close it again and I still am on the same page - no navigation to an other page...
I put in the html/css/js code in the module and that works fine for 1 modal module in the template. But if I want to use multiple of these custom modal module in my landing page template, I face the issue that I need a dynamic id for the modal div and the button in order to show the right content and close the right div.
Therefore, my idea was to use a text HubL-variable, where the user (that creates the template) can put in a unique id (e.g. modal_1, modal_2 etc. or content specific modal_productname etc.) for each of the multiple modules.
However, the problem is if I use this value of the HubL Variable for a javascript variable name, it does not work due to the fact that the HubL-Variable is shown with square brackets (e.g. "[modal_1]" instead of just the value "modal_1". See screenshot:
code of Hubspot modulesquare brackets in HTML
Is it possible to use the HubL-variable content without the square brackets? Or any other idea how to implement this use case?
@Deborah, I think your issue is caused by a repeater. In fact, when you create a repeater it creates a table which stores everyone iteration of your values. In this case you just set one value so the output is a table with only one value.
I tested it on my own and the code is working 😉
Bonus: I think I created what you were looking for in a simple way so enjoy!
If you want to create a repeater just put the fields in a group, transform it into a repeater and replace all the "module" values by "item" in the html. Then just wrap the html code in a for loop as this example:
{% for item in module.field_group %}
<--- HTML --->
{% endfor %}
@Deborah, I think your issue is caused by a repeater. In fact, when you create a repeater it creates a table which stores everyone iteration of your values. In this case you just set one value so the output is a table with only one value.
I tested it on my own and the code is working 😉
Bonus: I think I created what you were looking for in a simple way so enjoy!
If you want to create a repeater just put the fields in a group, transform it into a repeater and replace all the "module" values by "item" in the html. Then just wrap the html code in a for loop as this example:
{% for item in module.field_group %}
<--- HTML --->
{% endfor %}
thanks for your advice! It now works. And thank you @natsumimori for managing the communication. 😊
My problem was solved, if I create a new field without the repeater option. Then the suqare brackets disappeared. In the previous version the repeater option was some time ago activated, but then I deactived it,... but the square brackets didnt disappear. It had to be a newly created field.