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

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-shopify/

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


      {% 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 %}
    

#### {{ collection.title | escape }}
 
    

  {% endif %}

 
{% 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] }}

  
{% endfor %}      
    

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:

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

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

https://mapetitepointure.com/

Thanks @Zqdo

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?

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.