Insert Featured Collection Preview within a blog post using Impulse theme pre-configured Section

Insert Featured Collection Preview within a blog post using Impulse theme pre-configured Section

mpp-france
Tourist
6 0 0

Hi there, 

 

I am trying to find a way to inject a preview of a collection of products within several blog posts of my website. I use the Impulse 7.2 theme. The collection preview (aka featured collection) can be different depending on the blog post. 

 

I followed the tutorial here https://thefunction.works/how-to-add-product-blocks-inside-your-blog-using-nothing-but-liquid-shopif... 

 

And instead of referring to individual product handles, I would like instead to refer to collection handles. 

 

So here the code I inserted inside article-template.liquid

 

 

 

 <div class="article__body rte">
      {% assign divider = '[COLLECTION]' %}
{% assign dividerClose = '[/COLLECTION]' %}
{% assign text = article.content | split: divider %}

{{ text[0] }}
  
{% for divider in text offset:1 %}
  {% assign x = forloop.index %}
  {% assign newtext = text[x] | split: dividerClose %}
  {% assign collectionHandle = newtext[0] %}                        
  {% assign collection = collections[collectionHandle] %}
  {% if collection.products.size > 0 %}
    <div>
<h4>{{ collection.title | escape }}</h4>
 
    </div>
  {% endif %}

 <!-- Render collection preview here -->
{% for product in collection.products limit: 3  %}
       {% include 'product-grid-item' %}
      {% else %}
        {% for i in (1..product_limit) %}
          {% include 'product-grid-item' %}
        {% endfor %} 
      {% endfor %}
  
    {{ newtext[1] }}<br>
  
{% endfor %}      
    </div>

 

 

 

 

As you can see i have replaced PROD by COLLECTION and will be using the Collection handle as an input inside the blog.

 

What i would like to do is to replace the rendering of the collection shown below

 

 

 

{% for product in collection.products limit: 3  %}
       {% include 'product-grid-item' %}
      {% else %}
        {% for i in (1..product_limit) %}
          {% include 'product-grid-item' %}
        {% endfor %} 
      {% endfor %}

 

 

 

 

with the proper Impulse featured collection "section" that is used here and there on my website including the homepage. Here is an example:

mppfrance_0-1687900334596.png

 

I'm new to liquid programming, i did find the section called "featured-collection.liquid" but i couldn't find a way to render such section within the article-template.liquid. Even by using the render function instead of include.

 

It seems that it is not possible to render a section within another section. And instead i should be rendering snippets. Is there a snippet that includes all the logic of the featured collection of the Impulse theme as shown on the screenshot ?

 

Thanks a lot for your support!

Marc

 

Replies 4 (4)

Zqdo
Shopify Partner
803 32 64

Glad to help. Can you send over the link to your website so I can take a look?

banned
mpp-france
Tourist
6 0 0

Aurnik
Shopify Partner
51 1 4

Hey Marc --

1) Are you looking to insert one collection per blog post or will it vary?

2) Is there a specific way you want to display the collection, or are you saying you want it exactly like that featured collection you included?

Product Embed - embed products into blog posts - shopify.com/product-embed
Blog Sync - copy new & updated blog posts across stores - shopify.com/blog-sync
mpp-france
Tourist
6 0 0

Hello Aurnik, thanks for your relevant questions. 

1) I intend to insert one or more collection per blog post. So it varies indeed.

2) no specificity, so just like the featured collection in the screenshot, maybe not more than 4 products within 1 single row.