Liquid Template Variables - collections: Difference between revisions

From Spiffy Stores Knowledge Base
Jump to: navigation, search
Admin (talk | contribs)
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...
 
Admin (talk | contribs)
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
The liquid variable '''collections''' contains a collection of all of the store's [[Liquid_Template_Variables_-_collection|collections]].
The Liquid template variable '''collections''' contains a collection of all of the store's [[Liquid_Template_Variables_-_collection|collections]].


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


These examples print the names of all the products in the ''frontpage'' collection.
These examples print the names of all the products in the ''frontpage'' collection.
== Further Reference ==
* [[Liquid Basics]]
* [[Liquid Tag Reference]]
* [[Liquid Filter Reference]]
* [[Liquid Variable Reference]]
* [[Liquid Paginate Tag|Pagination ]]

Latest revision as of 13:11, 25 June 2018

The Liquid template 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.

Further Reference