Open CedricRobitaille opened 4 years ago
You could do it with a for-loop, kinda like this:
{% assign random_products=site.products|sample:3 %}
{% endif %}
Where the |sample:3
will pick 3 random things from inside the products
collection.
@thomasjbradley When doing that, I get the terminal error of "Unknown tag 'endif' in landing.html" pointing to the {% assign random_products=site.products|sample:3 %}.
Here's what I have. I set the sample count to 1 since I only have one card made as of now. {% assign random_products=site.products|sample:3 %}
{% endif %}
Additionally, I would like to know how to seek a specific product on a page (ie: Place the newest product on the homepage).
Oh yeah! My code above is missing a whole line! And it has a typo! How did that happen?
{% assign random_products=site.products|sample:3 %}
{% for product in random_products %}
{% endfor %}
@thomasjbradley That worked perfectly fine.
A final question I have regarding this page is, how can I display a card for a specific product. (ie: Popular or blog.
Something like this should work:
{% assign product=site.products[2] %}
{% pattern cards/product-card data=product %}
Seen in the index.html page.
Questions:
@thomasjbradley