--- layout: default title: collection nav: group: Liquid Variables --- # collection The collection object has the following attributes: {% table_of_contents %} {% comment %} Commenting out all_products and all_products_count as I don't see a purpose for them atm. The pagination limit for products and all_products is the same, so what is the difference? {% anchor_link "collection.all_products", "collection.all_products" %} Returns all of the products inside a collection. Note that there is a limit of 50 products that can be shown per page. Use the pagination tag to control how many products are shown per page. {% anchor_link "collection.all_products_count", "collection.all_products_count" %}

Returns the number of products in a collection.

Input

{% highlight html %}{% raw %} {{ collection.all_products_count }} {{ collection.all_products_count | pluralize: 'Item', 'Items' }} total {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} 24 Items {% endraw %}{% endhighlight %}
{% anchor_link "collection.all_tags", "collection.all_tags" %} Returns all tags of all products of a collection. This includes tags of products that are not in the current pagination view. {% highlight html %}{% raw %} {% if collection.all_tags.size > 0 %} {% for tag in collection.all_tags %} {% if current_tags contains tag %}
  • {{ tag | link_to_remove_tag: tag }}
  • {% else %}
  • {{ tag | link_to_tag: tag }}
  • {% endif %} {% endfor %} {% endif %} {% endraw %}{% endhighlight %} # {% endcomment %} {% anchor_link "collection.all_types", "collection-all_types" %}

    Returns a list of all product types in a collection.

    Input

    {% highlight html %}{% raw %} {% for product_type in collection.all_types %} {{ product_type | link_to_type }} {% endfor %} {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} Accessories Chairs Shoes {% endraw %}{% endhighlight %}
    {% anchor_link "collection.all_vendors", "collection-all_vendors" %}

    Returns a list of all product vendors in a collection.

    Input

    {% highlight html %}{% raw %} {% for product_vendor in collection.all_vendors %} {{ product_vendor | link_to_vendor }} {% endfor %} {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} Shopify Shirt Company Montezuma {% endraw %}{% endhighlight %}
    {% anchor_link "collection.current_type", "collection-current_type" %} Returns the product type when filtering a collection by type. For example, you may be on a collection page filtered by a type query parameter via this URL: myshop.shopify.com/collections?types=shirts.

    Input

    {% highlight html %}{% raw %} {% if collection.current_type %} {{ collection.current_type }} {% endif %} {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} shirts {% endraw %}{% endhighlight %}
    {% anchor_link "collection.current_vendor", "collection-current_vendor" %} Returns the vendor name when filtering a collection by vendor. For example, you may be on a collection page filtered by a vendor query parameter via this URL: myshop.shopify.com/collections/vendors?q=Shopify.

    Input

    {% highlight html %}{% raw %} {% if collection.current_vendor %} {{ collection.current_vendor }} {% endif %} {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} Shopify {% endraw %}{% endhighlight %}
    {% anchor_link "collection.default_sort_by", "collection-default_sort_by" %}

    Returns the sort order of the collection, which is set in the collection pages of the Admin.

    {{ '/themes/collection-sorting.jpg' | image }} The possible outputs are: - manual - best-selling - title-ascending - title-descending - price-ascending - price-descending - created-ascending - created-descending {% anchor_link "collection.description", "collection-description" %}

    Returns the description of the collection.

    {% anchor_link "collection.handle", "collection-handle" %}

    Returns the handle of a collection.

    {% anchor_link "collection.id", "collection-id" %}

    Returns the id of the collection.

    {% anchor_link "collection.image", "collection-image" %}

    Returns the collection image. Use the collection_img_url filter to link it to the image file on the Shopify CDN.

    Input

    {% highlight html %}{% raw %} {{ collection.image | collection_img_url: 'medium' }} {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} //cdn.shopify.com/s/files/1/0087/0462/collections/collection-image_medium.png?v=1337103726 {% endraw %}{% endhighlight %}
    {% comment %} Commenting out since you can't actually change alt tag in admin. {% anchor_link "collection.image.alt", "collection.image.alt" %}

    Returns the collection image's alt tag.

    {% endcomment %} {% anchor_link "collection.image.src", "collection-image-src" %}

    Returns the relative URL to the collection image.

    Input

    {% highlight html %}{% raw %} {{ collection.image.src | collection_img_url: 'medium' }} {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} //cdn.shopify.com/s/files/1/0087/0462/collections/summer_collection_medium.png?v=1334084726 {% endraw %}{% endhighlight %}
    {% anchor_link "collection.next_product", "collection-next_product" %} Returns the URL of the next product in the collection. Returns nil if there is no next product. This output can be used on the product page to output "next" and "previous" links on the product.liquid template. For more information, see How to Navigate within a Collection. {% anchor_link "collection.previous_product", "collection-previous_product" %} Returns the URL of the previous product in the collection. Returns nil if there is no previous product. This output can be used on the product page to output "next" and "previous" links on the product.liquid template. For more information, see How to Navigate within a Collection. {% anchor_link "collection.products", "collection-products" %} Returns all of the products inside a collection. Note that there is a limit of 50 products that can be shown per page. Use the pagination tag to control how many products are shown per page. {% anchor_link "collection.products_count", "collection-products_count" %}

    Returns the number of products in a collection.

    Input

    {% highlight html %}{% raw %} {{ collection.all_products_count }} {{ collection.all_products_count | pluralize: 'Item', 'Items' }} total {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} 24 Items {% endraw %}{% endhighlight %}
    {% anchor_link "collection.template_suffix", "collection-template_suffix" %}

    Returns the name of the custom collection template assigned to the collection, without the collection. prefix or the .liquid suffix. Returns nil if a custom template is not assigned to the collection.

    Input

    {% highlight html %}{% raw %} {{ collection.template_suffix }} {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} no-price {% endraw %}{% endhighlight %}
    {% anchor_link "collection.title", "collection-title" %}

    Returns the title of the collection.

    Input

    {% highlight html %}{% raw %}

    {{ collection.title }}

    {% endraw %}{% endhighlight %}

    Output

    {% highlight html %}{% raw %} Frontpage {% endraw %}{% endhighlight %}
    {% anchor_link "collection.tags", "collection-tags" %}

    Returns all tags of all products in a collection.

    {% anchor_link "collection.url", "collection-url" %}

    Returns the URL of the collection.