CMS Development

PYoganathan
Contributor

Add a Newsletter Section within the Blog Post Listing

SOLVE

Hello team,

I was looking at the HUBL documentation and was looking for a way to find the index of all blog posts and insert a newsletter module after the 2nd post.  And after that, the rest of the recent blogs will appear. How can I create an array or list of blog feed so that I can inject the newsletter column like the design below?

 

Screen Shot 2021-05-14 at 4.41.15 PM.png

0 Upvotes
1 Accepted solution
jonchim
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Add a Newsletter Section within the Blog Post Listing

SOLVE

Hey @PYoganathan,

You can try using something like the below using loop.index. Let me know if this works for you or if you're lookign for another solution

 

{% for content in contents %}
{% if loop.index == 1 %}
      /*==== Your First Post Content ====*/
{% endif %}
{% endfor %}

 

/*==== Your Newsletter Module Content ====*/

 

{% for content in contents %}
{% if loop.index > 2  %}
/*=== The rest of your Post listing Content ====*/
{% endif %}
{% endfor %}






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution

View solution in original post

3 Replies 3
jonchim
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Add a Newsletter Section within the Blog Post Listing

SOLVE

Hey @PYoganathan,

You can try using something like the below using loop.index. Let me know if this works for you or if you're lookign for another solution

 

{% for content in contents %}
{% if loop.index == 1 %}
      /*==== Your First Post Content ====*/
{% endif %}
{% endfor %}

 

/*==== Your Newsletter Module Content ====*/

 

{% for content in contents %}
{% if loop.index > 2  %}
/*=== The rest of your Post listing Content ====*/
{% endif %}
{% endfor %}






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
PYoganathan
Contributor

Add a Newsletter Section within the Blog Post Listing

SOLVE

Thank you @jonchim! This solution worked. Although the newsletter is appearing after the 1st post on the listing. I assume it's just a matter of changing the values of the if statement loop index to get it to appear after the 2nd post.

0 Upvotes
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Add a Newsletter Section within the Blog Post Listing

SOLVE

Awesome @PYoganathan! ahh read your post wrong so instead of loop.index == 1 you can do 

{% if loop.index == 1 or loop.index == 2 %}

and then 

{% if loop.index > 3  %}






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
0 Upvotes