We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Oct 22, 2018 9:39 AM
Hello all,
My issue here is that I'm creating a custom module with and img tag inside and using it on the Article template.
{% if module.vertical_image_field.src %} <img src="{{ module.vertical_image_field.src }}" alt="{{ module.vertical_image_field.alt }}" width="{{ module.vertical_image_field.width }}" height="{{ module.vertical_image_field.height }}"> {% endif %} <p>I am a custom module</p>
I want to call my custom module to the blog_listing template but module doesn't print.
I am using this code on my listing template
{{ content.widgets.vertical_image_field.src }}
Any ideas or small example of how to use custommodule inside other template with code is appreceiated.
Oct 22, 2018 10:45 AM
try inspecting the data in allWidgets, to see if what you're looking for is in there
{{content.allWidgets|pprint}}
Oct 24, 2018 11:36 AM - edited Oct 25, 2018 4:49 PM
that is some of that fancy hubspot wizard stuff @tjoyce pulls out of his hat 🙂
i didnt know allWidgets was a thing
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |
Nov 8, 2018 7:12 AM
Any of these solves my problem. Any ideas?
bump!
Oct 23, 2018 3:35 AM
Ι used the provided code but it prints nothing. I get a huge space.
Oct 23, 2018 9:09 AM
@WEDIA - I'm confused by your first screenshot. Why is there html rendering in the rendered view? Or, are you screenshotting your code view? The pprint should appear in the preview of your page, not in the code editor. If you still don't see anything in allWidgets, try just doing {{content|pprint}}, it's a great way to debug and figure out the right way to traverse the content dictionary.
Oct 24, 2018 3:18 AM
The previews screenshot comes from the module's code. I used
{{ content|pprint }}
and this module is not printed because it's not drag n' droped on my Blog Listing page. This module is drag n dropped on the Article Page which is printed (adds a new vertical image for the article).
I need to get this module with code to work on my Blog Listing Page for every article i print there.
When i use on the listing template
{{ content.widgets.allWidgets|pprint }}
I get null
Oct 24, 2018 10:13 AM
not content.widgets.allWidgets... it should be content.allWidgets
Oct 24, 2018 10:31 AM
Ok this worked. I got the custom module.
How can i now just get the image source?
Oct 24, 2018 10:37 AM
I can't test this code right now but, it would be something like this:
{% for w in content.allWidgets %} {% if w.label == "Vertical Image and more" %} //try {{w.pprint}} if w.body.src doesn't work... you might need to adjust the way you're calling src {{w.body.src}} {% endif %} {% endfor %}
Oct 25, 2018 3:42 AM
I tried all these below but i get empty html.
<div>{% module "module_1540413242653377" module_id="4162689" label="Vertical Image and more" %}</div> {% for w in content.allWidgets %} {% if w.label == "Vertical Image and more" %} <div class="print">{{w.pprint}}</div> <div class="vertical-image">{{w.vertical_image_field.src}}</div> {% endif %} {% endfor %}