Created
April 14, 2020 04:23
-
-
Save gbrits/6dc2d72d2b63d0b278c7c1b16e5492f1 to your computer and use it in GitHub Desktop.
Shopify $_GET variables via Liquid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Add this at the top of your page template --> | |
{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%} | |
{%- assign pageUrl = contentForQuerystring | split:'"pageurl":"' | last | split:'"' | first | split:'.myshopify.com' | last | | |
replace:'\/','/' | | |
replace:'%20',' ' | | |
replace:'\u0026','&' | |
-%} | |
{%- unless pageUrl contains "?" -%}{% break %}{%- endunless -%} | |
{%- assign pageQuerystring = pageUrl | split:'?' | last -%} | |
{%- assign tag = pageQuerystring | split:'=' | last -%} | |
{%- assign query_tags = tag | split: "," -%} | |
<!-- Try adding ?tag=blah,blah2,blah3" at the end of your page's URL. --> | |
<!-- // Example: --> | |
{{ query_tags | json }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For now it's probably just best to stick to good ol' JavaScript: