Skip to content

Instantly share code, notes, and snippets.

@Cam
Created October 30, 2019 06:16
Show Gist options
  • Save Cam/8679e020150dc7dc3b2e173753082f9d to your computer and use it in GitHub Desktop.
Save Cam/8679e020150dc7dc3b2e173753082f9d to your computer and use it in GitHub Desktop.
Get properties from global objects in liquid for Shopify
{%- assign object = block.settings.url -%}
{%- if object -%}
{%- if object.type == 'page_link' -%}
{%- assign object = block.settings[link] | remove: '/pages/' -%}
{%- assign title = pages[object].title -%}
{%- elsif object.type == 'collection_link' -%}
{%- assign object = block.settings[link] | remove: '/collections/' -%}
{%- assign title = collections[object].title -%}
{%- elsif object.type == 'product_link' -%}
{%- assign object = block.settings[link] | remove: '/products/' -%}
{%- assign title = all_products[object].title -%}
{%- elsif object.type == 'blog_link' -%}
{%- assign object = block.settings[link] | remove: '/blogs/' -%}
{%- assign title = blogs[object].title -%}
{%- elsif object.type == 'article_link' -%}
{%- assign object = block.settings[link] | remove: '/blogs/' -%}
{%- assign title = articles[object].title -%}
{%- elsif object.type == 'policy_link' -%}
{%- assign object = block.settings[link] | remove: '/policies/' | replace: '-', '_' -%}
{%- assign title = shop[object].title -%}
{%- endif -%}
{%- endif -%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment