Difference between revisions of "Liquid Variable Reference"

From Spiffy Stores Knowledge Base

 
(40 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Following is a reference-list of objects which you can use in your liquid templates. For an introduction to liquid templates you can check out the [[Liquid Basics | Liquid Basics]] page.
+
The following is a reference list of objects which you can use in your liquid templates. For an introduction to liquid templates you can check out the [[Liquid Basics | Liquid Basics]] page.
  
== Requirements ==
+
==Requirements==
  
Following variables have to be included in every liquid theme file such as the [[Theme.liquid | theme.liquid]].
+
Following variables must  be included in every Liquid theme file such as the [[Theme.liquid | theme.liquid]].
  
 
* <pre>{{content_for_header}}</pre>
 
* <pre>{{content_for_header}}</pre>
Line 10: Line 10:
 
== Template specific objects ==
 
== Template specific objects ==
  
Special purpose templates usually export the object they reference by the same name as the template file. Product.liquid, for example, would export a product object which references the current product on the page.
+
Special purpose templates usually export the object they reference by the same name as the template file. <code>Product.liquid</code>, for example, would export a product object which references the current product on the page.
  
=== index.liquid ===
+
===[[Index.liquid|index.liquid]]===
  
This template creates your store's home page. It is not directly related to any given resource of your store in the same way that product.liquid is.
+
This template creates your store's home page. It is not directly related to any given resource of your store in the same way that <code>Product.liquid</code> is.
  
Because it does not refer to a specific resource, index.liquid makes use of the global objects referenced below. You are free to use any objects (product, collection, page, etc.) in your store from here.
+
Because it does not refer to a specific resource, [[Index.liquid|index.liquid]] makes use of the global objects referenced below. You are free to use any objects (product, collection, page, etc.) in your store from here.
  
By convention the default themes will render all articles of a blog with the handle home-page, if it exists, and will display products from a collection with the handle home-page. Both of these objects are created automatically during the Spiffy Stores signup when your new store is created.
+
By convention the default themes will render all articles of a blog with the handle home-page, if it exists, and will display products from a collection with the handle home-page. Both of these objects are created automatically during the Spiffy Stores signup when your new store is created.
  
=== product.liquid ===
+
===[[Product.liquid|product.liquid]]===
  
The referenced product with several variants.
+
This template displays the referenced [[Liquid_Template_Variables_-_product|product]] and all its variants.
  
=== blog.liquid ===
+
===[[Blog.liquid|blog.liquid]]===
  
blog which has several article objects.
+
This template is used to display a [[Liquid_Template_Variables_-_blog|blog]] and its [[Liquid_Template_Variables_-_article|articles]].
  
=== collection.liquid ===
+
===[[Collection.liquid|collection.liquid]]===
  
collection which references several product and tags objects. Collections usually make use of pagination.
+
This template is used to display a collection of [[Liquid_Template_Variables_-_product|products]] and all the tags for the collection.
  
=== page.liquid ===
+
This template will usually use [[Liquid_Paginate_Tag|pagination]] to help to display a large number of items.
  
page
+
===[[Page.liquid|page.liquid]]===
  
=== cart.liquid ===
+
This template provides the basic support for displaying the static [[Liquid Template Variables - page|pages]] for your store.
  
cart with many line_items
+
=== [[Cart.liquid|cart.liquid]] ===
  
== Global objects ==
+
This template contains the layout for your shopping [[Liquid Template Variables - cart|cart]], and will show all the items that the customer has selected for purchase.
  
Following objects are available from any liquid template in the system. You can use those
+
=== [[Search.liquid|search.liquid]] ===
  
    * cart
+
This template contains the layout for your [[Liquid_Template_Variables_-_search|search]] results.
    * collections
+
 
    * linklists
+
=== [[404.liquid|404.liquid]] ===
    * pages
+
 
    * blogs
+
This template will be displayed whenever a page, product or collection cannot be found. It gives you the opportunity to redirect your customers to a search page or some other way of helping them find what they are looking for.
    * shop
+
 
    * template
+
=== [[list-collections.liquid|list-collections.liquid]] ===
 +
 
 +
This template displays all of the collections in your store except the home page collection. In many cases the behaviour can be overridden by creating a menu called "Collections".
 +
 
 +
== Global Objects ==
 +
 
 +
Following objects are available from any Liquid template in the system.
 +
 
 +
* [[Liquid Template Variables - template|template]]
 +
* [[Liquid Template Variables - page_title|page_title]]
 +
* [[Liquid Template Variables - page_description|page_description]]
 +
* [[Liquid Template Variables - shop|shop]]
 +
* [[Liquid Template Variables - cart|cart]]
 +
* [[Liquid Template Variables - products|products]]
 +
* [[Liquid Template Variables - collections|collections]]
 +
* [[Liquid Template Variables - linklists|linklists]]
 +
* [[Liquid Template Variables - pages|pages]]
 +
* [[Liquid Template Variables - blogs|blogs]]
 +
* [[Liquid Template Variables - request|request]]
 +
* [[Liquid Template Variables - cookies|cookies]]
 +
* [[Liquid Template Variables - header|header]]
 +
* [[Liquid Template Variables - canonical_url|canonical_url]]
 +
* [[Liquid Template Variables - exchange_rate|exchange_rate]]
 +
* [[Liquid Template Variables - gift_card|gift_card]]
 +
 
 +
== Conditional Objects ==
 +
 
 +
If a customer is logged in
 +
 
 +
* [[Liquid Template Variables - customer|customer]]
 +
* [[Liquid Template Variables - customer_credit|customer_credit]]
 +
 
 +
== Other Objects ==
 +
 
 +
The following objects are referenced by other Liquid Template Variables, and may be accessed from those objects, rather than being referenced directly.
 +
 
 +
* [[Liquid Template Variables - metafields|metafields]]
 +
 
 +
== Further Reference ==
 +
 
 +
* [[Liquid Basics]]
 +
* [[Liquid Tag Reference]]
 +
* [[Liquid Filter Reference]]
 +
* [[Liquid Paginate Tag|Pagination ]]

Latest revision as of 12:04, 28 January 2022

The following is a reference list of objects which you can use in your liquid templates. For an introduction to liquid templates you can check out the Liquid Basics page.

Requirements

Following variables must be included in every Liquid theme file such as the theme.liquid.

  • {{content_for_header}}
  • {{content_for_layout}}

Template specific objects

Special purpose templates usually export the object they reference by the same name as the template file. Product.liquid, for example, would export a product object which references the current product on the page.

index.liquid

This template creates your store's home page. It is not directly related to any given resource of your store in the same way that Product.liquid is.

Because it does not refer to a specific resource, index.liquid makes use of the global objects referenced below. You are free to use any objects (product, collection, page, etc.) in your store from here.

By convention the default themes will render all articles of a blog with the handle home-page, if it exists, and will display products from a collection with the handle home-page. Both of these objects are created automatically during the Spiffy Stores signup when your new store is created.

product.liquid

This template displays the referenced product and all its variants.

blog.liquid

This template is used to display a blog and its articles.

collection.liquid

This template is used to display a collection of products and all the tags for the collection.

This template will usually use pagination to help to display a large number of items.

page.liquid

This template provides the basic support for displaying the static pages for your store.

cart.liquid

This template contains the layout for your shopping cart, and will show all the items that the customer has selected for purchase.

search.liquid

This template contains the layout for your search results.

404.liquid

This template will be displayed whenever a page, product or collection cannot be found. It gives you the opportunity to redirect your customers to a search page or some other way of helping them find what they are looking for.

list-collections.liquid

This template displays all of the collections in your store except the home page collection. In many cases the behaviour can be overridden by creating a menu called "Collections".

Global Objects

Following objects are available from any Liquid template in the system.

Conditional Objects

If a customer is logged in

Other Objects

The following objects are referenced by other Liquid Template Variables, and may be accessed from those objects, rather than being referenced directly.

Further Reference