Access querystring in Liquid

Matthew_Capewel
Tourist
85 0 2
Is there a way to access the contents of the URL querystring in Liquid? For example I would like to do something similar to the following: http://oursite.myshopify.com/products/my-product?a=123 {{ Product.Request.a }} would output: 123
Replies 10 (10)
Luka_Koczorowsk
Shopify Partner
10 0 6

Extending 's solution

 

Under snippets save the following as fn.querystring.liquid:

{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}
{%- assign pageUrl = contentForQuerystring | split:'"pageurl":"' | last | split:'"' | first | split:'.myshopify.com' | last |
   replace:'\/','/' | 
   replace:'%20',' ' | 
   replace:'\u0026','&'
-%}
{%- assign itemShow = '' -%}
{%- for i in (1..1) -%}
  {%- unless pageUrl contains "?" -%}{% break %}{%- endunless -%}
  {%- assign pageQuerystring = pageUrl | split:'?' | last -%}
  {%- assign parts = pageQuerystring | split:'&' -%}
  {%- for part in parts -%}
    {%- assign keyAndValue = part | split:'=' -%}
    {%- if keyAndValue.size > 1 -%}
      {% if keyAndValue[0] == param %}{{keyAndValue[1]}}{% endif %}{%- endif -%}{%- endfor -%}{%- endfor -%}

And then where ever you need a parameter from the query string:

{% capture qs_view %}{%- render 'fn.querystring', param: "view" -%}{% endcapture %}
{% capture qs_version %}{%- render 'fn.querystring', param: "ver" -%}{% endcapture %}
<!--  Using template {{qs_view}}, version {{qs_version}} -->

Note: capture captures whitespace so capture's have to be one-liners. It's also why the final line of fn.querystring.liquid is one line.