CMS Development

tementa
Member

Embed a form in post listing

Hi, 

I want to embed a form in the post listing of my blog? How this can be done?

I found this template with the embeded form.

http://psdtohubspot-2432204.hs-sites.com/news-blogScreen-Shot-2018-11-20-at-11.19.30.png

0 Upvotes
2 Replies 2
AJLaPorte_diagr
Key Advisor

Embed a form in post listing

Hi @tementa,

 

With the template you are looking at, it appears they are using Javascript to insert that particular element into that slot:

 

<script>
$('.subscribe-card').slice().insertAfter('.news-post-item:nth-child(2)'); 
</script>

You should also be able to do something like this in your content loop using HubL for your blog to add in an item after the 2nd listing item:

 

{% if loop.index == 2%}
	<div class="post-item grid-item">ADD AFTER 2nd ITem</div>
{%endif%}

You would then need to use CSS to make sure your grid is positioned correctly. Note, that if you are using paginated content, the above would add this on every page where the loop outputs. If you only wanted it on page one, you would also have to include a conditional to take the current_page_num variable into account. 

 

Hopefully, this helps point you in the correct direction. 

 

-AJ

-----------------------
AJ LaPorte
www.wsol.com

 

 

 

tementa
Member

Embed a form in post listing

Hi AJ LaPorte, 

 

We maybe change the blog layout, but we'll try your solution for sure.

Thank so much for your answer 😉

 

Rafa

0 Upvotes