{% query_param_link %}

This tag saves or outputs a link to the current page as it was loaded except with the specified query parameters added, removed, or changed to their new values

Syntax

Syntax: {% query_param_link [[var|set|assign] new_variable_name =] parameter1:value [parameter2:'etc...'] %}

This tag will either save the link to a variable or output it to the page, depending on if you have specified a variable to save the link to.

If you are assigning the link to a variable and do not specify one of "var", "set", or "assign", then the "var" behavior will be used - which is to save the result on the current scope. If new_variable_name starts with '&', will attempt to assign the value by reference.

This tag will accept any number of parameters and evaluate them before replacing them in the URL. You may also include reference variables, which will be dereferenced into their parameter names.

To remove a query parameter from the URL, set it to false (parametername:false).

Examples

Original URL: "http://www.domain.com/path/to/page"
Template: <a href="{% query_param_link page:2 %}">Page 2<a>
Output: <a href="http://www.domain.com/path/to/page?page=2">Page 2<a> 
Original URL: "http://www.domain.com/path/to/page?page=2"
Template: {% var numLinks = 3 %}
{% query_param_link mylink = page:1 limit:numLinks topic:'Patriotism' %}
<a href="{{ mylink | Append:"#articletop" }}">Top {{ numLinks }} Patriotic Articles<a>
Output: <a href="http://www.domain.com/path/to/page?page=1&limit=3&topic=Patriotism#articletop">Top 3 Patriotic Articles<a> 
Original URL: "http://www.domain.com/path/to/page?flat=true"
Template: {% var oldvarname = 'flat' %}
{% var newvarname = 'round' %}
<a href="{% query_param_link &oldvarname:false &newvarname:'true' %}">
Output: <a href="http://www.domain.com/path/to/page?round=true">

Developer Overview

Liquid Markup