CMS Development

deiviser
Participante | Partner
Participante | Partner

How do I pass field values from module with a repeater to a template?

resolver

Hello,

 

I'm quite new to HubSpot and really struggling with this build.


I've made a module with a repeater that allows me to post job listings. Each red box is whats added by the repeater.

deiviser_1-1642697687757.png

When they click apply button, it takes them to a form page with some dynamic text and a form.

deiviser_2-1642697860542.png


Is it possible to pull location and job role from the previous page, to this form page depending on which box they clicked "Apply" on?

{% inline_text field="job_role" value="{{ item.job_role }}"

{{ item.job_location }}

 

I've tried messing with export_to_template_context, but I can't quite grasp it and I'm not even sure its what I need.

 

My thinking is to pass information through URL parameters, but I don't see a way to do so either unless its a contact property.


I might be overcomplicatng things, so any advice/steer in the right direction would be appreciated.

 

 

0 Me gusta
1 Soluciones aceptada
Kevin-C
Solución
Experto reconocido | Partner
Experto reconocido | Partner

How do I pass field values from module with a repeater to a template?

resolver

Hey @deiviser 

 

So export_to_template context only allows to the template containing the parameter to use it. To do this you can do a few things. Query param, local storage or cache. For your use case and reliability (thanks safari) query paras will be the best method!

 

{% for item in module.repeater %}
  <a href="{{ item.url ~ "?param=" ~ item.value }}">Apply</a>
{% endfor %}

 

 

You can then access this value on the redirected page using:

 

{{ Query.param }}

 

 

Let me know if this gets you moving!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev

Ver la solución en mensaje original publicado

3 Respuestas 3
deiviser
Participante | Partner
Participante | Partner

How do I pass field values from module with a repeater to a template?

resolver

Thank you both for your input. The first solution worked perfectly well with some adjustments. Thank you! 

For anyone else who needs something similar, my URL ended up looking like this:
<a href="{{ "mywebsite.com" ~ "?job_location=" ~ item.job_location ~ "&job_role=" ~ item.job_role }}" class="apply-button">Apply</a>

And to print values on the other page I used these:
{{request.query_dict.job_location}}
{{request.query_dict.job_role}}

webdew
Guía | Partner nivel Diamond
Guía | Partner nivel Diamond

How do I pass field values from module with a repeater to a template?

resolver

Hi @deiviser ,

I am not sure how is it possible to pull location and job role from previous page , but i can give alternative solution regard job page

You should make a job description template which include the Form section (which take detail of candidate) and a Text Content where you can add Job Role and details. Just create page for your job from job description template and add link in your Job listing i.e in Repeater apply button respectively.

Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.

Kevin-C
Solución
Experto reconocido | Partner
Experto reconocido | Partner

How do I pass field values from module with a repeater to a template?

resolver

Hey @deiviser 

 

So export_to_template context only allows to the template containing the parameter to use it. To do this you can do a few things. Query param, local storage or cache. For your use case and reliability (thanks safari) query paras will be the best method!

 

{% for item in module.repeater %}
  <a href="{{ item.url ~ "?param=" ~ item.value }}">Apply</a>
{% endfor %}

 

 

You can then access this value on the redirected page using:

 

{{ Query.param }}

 

 

Let me know if this gets you moving!

Kevin Cornett - Sr. Solutions Architect @ BridgeRev