Difference between revisions of "Liquid Template Variables - collections"

From Spiffy Stores Knowledge Base

(New page: The liquid variable '''collections''' contains a collection of all of the store's collections. You can access any collection by using the colle...)
(No difference)

Revision as of 16:17, 15 September 2008

The liquid variable collections contains a collection of all of the store's collections.

You can access any collection by using the collection handle to index the collections contained within the collections variable.

{% for product in collections.frontpage.products %}
   {{ product.title }}
{% endfor %}

You can also use a indexed-style access, using either a literal or a variable:

{% for product in collections['frontpage'].products %}
   {{ product.title }}
{% endfor %}

-- or --

{% assign: collectionName = 'frontpage' %}
{% for product in collections[collectionName].products %}
   {{ product.title }}
{% endfor %}

These examples print the names of all the products in the frontpage collection.