{{ query_params }}

Object containing all of the query string parameters for the current page.

Properties

Specific parameters may be accessed using {{ request.query_params.parametername }} or {{ request.query_params['parameter-name'] }}.

You may also treat this object as a list containing all of the query parameters which may be iterated using a {% for %} loop. For more details, see the examples below:

string object_type
Will always be "query_params"
true/false is_valid
Always true.
list by_index
A list of all of the query parameters in the order they appear in the URL. Each item in the list is the full query parameter - including both the key and the value. Note that this may include empty and/or duplicate query parameters.
object by_name
An object whose properties match the query parameters in the URL, including query parameters with empty values. If the same query parameter appears multiple times in the URL, the value will be a comma-separated list of all of the values for that key.
list keys
A list of all of the non-empty parameter names in the URL.
number count
The number of distinct query parameters (by name) in the URL.
number length
The total number of query parameters (by index) in the URL.

Examples

For the URL: www.domain.com/path/to/page?alpha=abc&beta=b&&emptyvariable&animals=cat&animals=dog&animals=fish

{{ request.query_params }} => alpha=abc&beta=b&&emptyvariable&animals=cat&animals=dog&animals=fish
{{ request.query_params.count }} => 4
{{ request.query_params.length }} => 7
{{ request.query_params.alpha }} => abc
{{ request.query_params.emptyvariable }} =>
{{ request.query_params['animals'] }} => cat,dog,fish
{{ request.query_params[1] }} => beta=b
{% if request.query_params has_key 'alpha' %}has alpha{% else %}no alpha{% endif %} => has alpha
{% if request.query_params contains 'animals=cat' %}cat{% else %}no cat{% endif %} => cat
{% for param in request.query_params %} --same as {% for param in request.query_params.by_index %}
    {% unless forloop.first %}, {% endunless %}{{param}}
{% endfor %}
=> alpha=abc, beta=b, , emptyvariable, animals=cat, animals=dog, animals=fish
{% for param in request.query_params.keys %}
    {% unless forloop.first %}; {% endunless %}{{param}}: {{request.query_params[param]}}
{% endfor %}
=> alpha: abc; beta: b; emptyvariable: ; animals: cat,dog,fish

Developer Overview

Liquid Markup