Difference between revisions of "Liquid Template Variables - collection"
From Spiffy Stores Knowledge Base
m |
|||
Line 32: | Line 32: | ||
{{ product.title }} | {{ product.title }} | ||
{% endfor %}</pre> | {% endfor %}</pre> | ||
+ | |||
+ | '''Warning''': A maximum of 50 products are returned unless pagination is being used. | ||
== <code>collection.products_count</code> == | == <code>collection.products_count</code> == | ||
Line 41: | Line 43: | ||
Returns a collection of all [[Liquid_Template_Variables_-_product|products]] that are associated with this ''collection''. | Returns a collection of all [[Liquid_Template_Variables_-_product|products]] that are associated with this ''collection''. | ||
− | '''Warning''': | + | '''Warning''': A maximum of 50 products are returned unless pagination is being used. |
+ | |||
+ | == <code>collection.all_products_count</code> == | ||
+ | |||
+ | Returns the number of all products in the collection. | ||
== <code>collection.tags</code> == | == <code>collection.tags</code> == |
Revision as of 10:24, 22 August 2013
The liquid template variable collection has the following attributes:
Contents
- 1 collection.id
- 2 collection.handle
- 3 collection.title
- 4 collection.description
- 5 collection.content
- 6 collection.products
- 7 collection.products_count
- 8 collection.all_products
- 9 collection.all_products_count
- 10 collection.tags
- 11 collection.all_tags
- 12 collection.next_product
- 13 collection.previous_product
- 14 collection.url
- 15 collection.all_types
- 16 collection.all_vendors
collection.id
Returns the unique internal number of the collection.
This is normally only for internal usage.
collection.handle
This is the collection handle. The handle uniquely identifies the collection in the URL address.
The handle is usually the collection's title in lower case with all blanks replaced by a dash. "Summer Sale" would have the handle "summer-sale".
collection.title
Returns the title of this collection.
collection.description
Returns the description of this collection.
collection.content
This is an alias of description.
collection.products
Returns a collection of all products that are associated with this collection, matching the current view. The current view is takes into account things like pagination and selected tags. You can access each product using a for iteration.
{% for product in collection.products %} {{ product.title }} {% endfor %}
Warning: A maximum of 50 products are returned unless pagination is being used.
collection.products_count
Returns the number of products in the collection.
collection.all_products
Returns a collection of all products that are associated with this collection.
Warning: A maximum of 50 products are returned unless pagination is being used.
collection.all_products_count
Returns the number of all products in the collection.
collection.tags
Returns all of the tags associated with all of the products in this particular collection which match the current view. This means that if the current view is filtered to only contain products with a certain tags, then this call will return all of the tags that the remaining products actually have.
<ul> {% for tag in tags %} <li>{{ '+' | link_to_add_tag: tag }} {{ tag | link_to_tag: tag }}</li> {% endfor %} </ul>
collection.all_tags
Returns all tags associated with the collection.
collection.next_product
Returns the next product in the collection, when your product pages have been scoped to a certain collection.
For a discussion of this, read How To Navigate Within A Collection.
collection.previous_product
Returns the previous product in the collection, when your product pages have been scoped to a certain collection.
For a discussion of this, read How To Navigate Within A Collection.
collection.url
The is the relative URL address of the collection.
collection.all_types
Returns a list of all unique product types in the collection. An array of types is returned.
Example usage:
<ul> {% for product_type in collection.all_types %} <li> {{ product_type | link_to_type }} </li> {% endfor %} </ul>
collection.all_vendors
Returns a list of all unique product vendors in the collection. An array of vendors is returned.
Example usage:
<ul> {% for product_vendor in collection.all_vendors %} <li> {{ product_vendor | link_to_vendor }} </li> {% endfor %} </ul>