While designing this blog Daniel wanted to display dates only if they actually changed since the last time.
We quickly came to realize that this is a great reusable pattern and we wanted to dedicate some first class support to this kind in liquid.
Ifchanged does exactly this. The block contained within ifchanged will only be rendered to the output if the last call to ifchanged returned different output.
Here is an example:
<h1>Product Listing</h1>
{% for product in products %}
{% ifchanged %}<h3>{{ product.created_at | date:"%w" }}</h3>{% endifchanged %}
<p>{{ product.title }} </p>
...
{% endfor %}
Topics:
Join 379,633 entrepreneurs who already have a head start.
Get free online marketing tips and resources delivered directly to your inbox.
Thanks for subscribing
You’ll start receiving free tips and resources soon. In the meantime, start building your store with a free 14-day trial of Shopify.