CMS Development

iliascarre
Participant | Platinum Partner
Participant | Platinum Partner

Pull img src variable from blog post module into blog listing page

SOLVE

I am essentially trying to pull the image src variable from a custom image module in a blog post into the blog post listing page. 

 

From Blog post Listing module:

<img src="{{ module.post_listing_image.src }}">

 

In the single blog post template:
{% block body %}
{# Image for Listing Page #}
{% module "module_160434676630624" path="/client_theme/modules/Blog-Post-Listing-Image", label="Blog-Post-Listing-Image" %}
{# END Image for Listing Page #} ....

 

In the blog listing template I have tried various things. Here is the gist of what I am attempting (to spare you all the attempted methods): 

<div class="blogpostlisting__listing">
{% for post in contents %}

<div class="blogpostlisting_image">

<img src="{{ post.module_160434676630624.post_listing_image.src }}">

</div>

{% endfor %}

 

Any help would be appreciated. Thank you! 

0 Upvotes
1 Accepted solution
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Pull img src variable from blog post module into blog listing page

SOLVE

There's actually a recent post answering this very question : 
https://community.hubspot.com/t5/CMS-Development/Using-a-custom-module-field-for-blog-post-in-the-li...

 

You had it quite close, believe you're just missing the 'widgets' and 'body' bit:

{{ post.widgets.module_160434676630624.body.post_listing_image.src }}  

 

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

View solution in original post

2 Replies 2
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Pull img src variable from blog post module into blog listing page

SOLVE

There's actually a recent post answering this very question : 
https://community.hubspot.com/t5/CMS-Development/Using-a-custom-module-field-for-blog-post-in-the-li...

 

You had it quite close, believe you're just missing the 'widgets' and 'body' bit:

{{ post.widgets.module_160434676630624.body.post_listing_image.src }}  

 

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
iliascarre
Participant | Platinum Partner
Participant | Platinum Partner

Pull img src variable from blog post module into blog listing page

SOLVE

@alyssamwilie Excellent! I saw that post some time after I posted this and was still tweaking my syntax to try and get it to work. It is working now. Thank you!

0 Upvotes