8.0 KiB
layout, title, landing_as_article, nav
| layout | title | landing_as_article | nav | ||||
|---|---|---|---|---|---|---|---|
| default | Objects | true |
|
Objects
Liquid objects contain attributes to output dynamic content on the page. For example, the product object contains an attribute called title that can be used to output the title of a product.
Liquid objects are also often refered to as Liquid variables.
To output an object's attribute on the page, wrap them in {{ and }}, as shown below:
{% highlight html %}{% raw %} {{ product.title }} {% endraw %}{% endhighlight %}
Global Objects
The following objects can be used and accessed from any file in your theme, and are defined as global objects, or global variables:
blogs |
{% highlight html %}{% raw %}
The liquid object |
cart |
The liquid object |
collections |
{% highlight html %}{% raw %}
{% for product in collections.frontpage.products %}
{{ product.title }}
{% endfor %}
{% endraw %}{% endhighlight %}
The liquid object |
current_page |
{% highlight html %}{% raw %}
{% if current_page != 1 %} Page {{ current_page }}{% endif %}
{% endraw %}{% endhighlight %}
The |
current_tags |
{% highlight html %}{% raw %}
{% if current_tags %}
{{ blog.title | link_to: blog.url }} › {{ current_tags.first }}{% else %}{{ blog.title }}{% endif %} {% endraw %}{% endhighlight %}The |
customer |
{% highlight html %}{% raw %}
{% if shop.customer_accounts_enabled %}
{% if customer %}
My Account
{{ 'Log out' | customer_logout_link }}
{% else %}
{{ 'Log in' | customer_login_link }}
{% if shop.customer_accounts_optional %}
{{ 'Create an account' | customer_register_link }}
{% endif %}
{% endif %}
{% endif %}
{% endraw %}{% endhighlight %}
The liquid object |
linklists |
{% highlight html %}{% raw %}
The liquid object |
pages |
{% highlight html %}{% raw %}
{{ pages.about.title }}{{ pages.about.author }} says... {{ pages.about.content }}
{% endraw %}{% endhighlight %}
The liquid object |
page_description |
{% highlight html %}{% raw %}
{% if page_description %}
{% endif %}
{% endraw %}{% endhighlight %}
Merchants can specify a |
page_title |
{% highlight html %}{% raw %}
{{ page_title }}
{% endraw %}{% endhighlight %}
The liquid object |
shop |
The liquid object |
template |
{% highlight html %}{% raw %}
{% if template contains 'product' %}
WE ARE ON A PRODUCT PAGE.
{% endif %}
{% endraw %}{% endhighlight %}
The liquid object |
settings |
{% highlight html %}{% raw %}
{% if settings.use_logo %}
{{ 'logo.png' | asset_url | img_tag: shop.name }}
{% else %}
{{ shop.name }}
{% endif %}
{% if settings.featured_collection and settings.featured_collection != '' and collections[settings.featured_collection].handle == settings.featured_collection and collections[settings.featured_collection].products_count > 0 %}
{% for product in collections[settings.featured_collection].products %}
{% include 'product-loop' %}
{% endfor %}
{% endif %}
{% endraw %}{% endhighlight %}
The liquid object |
theme |
{% highlight html %}{% raw %}
Go to your theme settings.
{% endraw %}{% endhighlight %}
The liquid object |
themes |
{% highlight html %}{% raw %}
We have a beautiful mobile theme, it's called {{ themes.mobile.name | link_to_theme: "mobile" }}
{% endraw %}{% endhighlight %}
The liquid object |