HubL: how to access module field from coded page template
Hello:
I have a coded template which uses a custom module (for header). That module has background image field. I understand that I can set default image for the MODULE - but then all pages will have the same image. My goal is to be able to set default image PER TEMPLATE - so I can have one image for all "blog" pages, and another one for all "FAQ" pages for example. Basically, I'm looking for something like this:
As you can see, the custom module contains an image but there is no src value for the image in the data so you cannot target the src to change it as you have tried.
I took the Image SRC module from above and placed it into the custom module though, and look at this data:
{% set widget_data.new_custom_module.exectve_image_src.src=image_url %}
HOWEVER notice that in all of these examples "export_to_template_context" is used. This is how you get to play with the data. without it you can not change stuff around like you are trying. With it you can BUT you have to call the elements onto the page using tokens:
Which is something you will find developers doing a lot in Hubspot for a lot of reasons. The biggest issue for you is that it isn't possible with custom modules!. Yes you can get the data from regular modules placed inside a custom module like did but you can't get native custom module field data to output on the page so either:
1. you set "export_to_template_context" to true rendering all of the fields of the custom module field unusable.
2. use the custom module like it should be but you won't get to do what you are wanting.
3. use a custom HTML module (if you are using the template builder) create you "custom module" here and make it global. you can then add it on any page you would like and do what you are wanting to do.