{go:query_string:html_encode}

Description

Builds a site URL from the page that is being viewed right now, then applies the changes you pass in the query string. Designed for the Site module: it reads the current router state (language, path segments, pager page, query string) and rewrites only the parts you name, leaving the rest in place. This makes it the canonical way to write internal links that stay on the same page or jump to a sibling section without hard-coding the full path. The query string is a list of name=value pairs joined by ampersands. Recognised names: xlang switches the interface language and resets to that language home; xseo1 through xseo9 set individual path segments (an empty xseoN cuts that segment and everything after it); xseoadd appends one extra segment to the current path; xpage sets the pager page (1 means no page suffix); xflag and xcat set the flag and category in the path prefix; xqs replaces the entire query string (xqs= alone clears it); and xqs_NAME sets or replaces a single query-string variable while keeping the others. Setting any xseo or xseoadd also clears the pager and query string. Pass 1 as the second argument to HTML-encode the result for safe use inside an attribute. Note: the URL is built relative to the page on which go runs - its language and current path - so the examples below show the representative URL a live page produces and are marked illustrative.

Parameters

query_string optional default (empty)

The changes to apply to the current page URL, written as name=value pairs joined by ampersands. Recognised names: xlang, xseo1..xseo9, xseoadd, xpage, xflag, xcat, xqs and xqs_NAME (see the description). Empty means return the current page URL unchanged.

html_encode optional default (empty)

Pass 1 to run the resulting URL through safe() so it is HTML-entity-encoded and safe to drop into an HTML attribute. Any other value (or empty) returns the raw URL.

Examples

virtual{go:xseo1=faq}
Expected(/en/faq)
Actual/en/faq
Set the first path segment. From any page on an English site this points the link at the faq section, keeping the current language. The standard way to write a more-link or menu link.
virtual{go:xseo1=about-project&xseo2=media}
Expected(/en/about-project/media)
Actual/en/about-project/media
Set two path segments at once. Joins the name=value pairs with an ampersand. Real-world: a read-more link from a home-page box to a sub-section.
virtual{go:xlang=de}
Expected(/de/)
Actual/de/
xlang switches the interface language and resets the path to that language home. Use it for language-switcher links.
virtual{go:xseoadd=detail}
Expected(/en/news/detail)
Actual/en/expression/go/detail
xseoadd appends one more segment after the current path instead of replacing a numbered one. Handy when you do not know how deep the current path already is.
virtual{go:xqs_year=2023}
Expected(/en/news?year=2023)
Actual/en/expression/go?year=2023
xqs_NAME sets or replaces a single query-string variable and preserves any others already on the URL. Here only year is changed.
virtual{go:xqs=}
Expected(/en/news)
Actual/en/expression/go
xqs= with no value drops the whole query string and returns the current path clean. Common as a form action or ok_url so a submit returns to the same page.
virtual{go:xqs_a=1&xqs_b=2:1}
Expected(/en/news?a=1&b=2)
Actual/en/expression/go?a=1&b=2
The second argument 1 runs the URL through safe(), so the ampersand joining query variables becomes & - correct when you drop the URL into an HTML href attribute.