Hi All, I would like to be able to add multiple featured collections into a blog post.
I currently use the Supply theme.
I currently have the ability to embed products into the blog posts using this wee snippet of code:
{% assign divider = '[PROD]' %}
{% assign dividerClose = '[/PROD]' %}
{% 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 productHandle = newtext[0] %}
{% assign product = all_products[productHandle] %}
{% include 'product-list-small-item' %}
{{ newtext[1] }}
{% endfor %}
this is goes in place of the article.content line.
Essentially, this allows me to put "[PROD]product-handle[/PROD] in the content of a blog post and this renders the product in the published post.
I would like the ability to adapt this to show the featured collection. I do not need both of these functioning at once and will probably use separate article templates
Here is a link for one of the blog pages that contains product embeds.
https://www.powertoolpeople.co.nz/blogs/knowledge/dust-extraction
the collection at the bottom is generated with the following code:
{%- assign tag = article.image.alt -%}
{%- assign collection = collections[tag] -%}
{%- assign product_limit = 6 -%}
{% if collection.products.size > 0 %}
## Shop {{ collection.title | escape }}
{% for product in collection.products limit: product_limit %}
{% include 'product-blog-item' %}
{% else %}
{% for i in (1..product_limit) %}
{% include 'placeholder-product-blog-item' %}
{% endfor %}
{% endfor %}
## See All
{%endif%}
This uses the alt text for the featured image to define the collection, limiting me to just one and putting it at the bottom of the page.