ONEPOINTONE
ONEPOINTONE

Reputation: 27

Shopify template not triggering liquid scripting language

I am new to shopify liquid, I am trying to get a specific collection to be output to page, but i not sure why liquid part is not functioning. The text is displaying and page.content works but nothing work on for loop

page name is "page.test.liquid"

I'm using this for a template for page called monthly products

{%- assign collection = collections['past-crates'] -%} <-- always add this if not in collection page, and make sure you set collection properly

{{ page.content }}

{%- assign collection = collections['past-crates'] -%}

{%- for product in collection.products -%}
 {{product.title | capitalize}}
{%- endfor -%}

Upvotes: 1

Views: 140

Answers (1)

davidthorand
davidthorand

Reputation: 403

The collection object is nil unless you are on a collection page. If you want to access a specific collection object on another page you can access it via the global collections object:

{%- assign collection = collections['your-collection-handle'] -%}

Upvotes: 3

Related Questions