Hi David,
The newest plugin version has a feature that should work as you expected: the Format
tag with attribute url_query
will convert a given text to be suitable for URL query string.
<Format url_query>5500 Grand Lake Drive, San Antonio, TX</Format>
The above should output:
5500%20Grand%20Lake%20Drive%2C%20San%20Antonio%2C%20TX
As Ben pointed out, <Format code>
uses htmlspecialchars, whereas the conversion you’re looking for is, I believe, rawurlencode.
I named the format type url_query
, because it’s only suitable for a URL query string, not the whole URL, which can include characters like /
and ?
.
For example, the following:
<Format url_query>https://example.com/?query=...</Format>
…becomes…
https%3A%2F%2Fexample.com%2F%3Fquery%3D...
So the main part of the URL needs to be outside of the Format tag.
I imagine you’d like to use the formatted URL query in a link. In that case, it might be easier to set the formatted value in a variable first, like:
<Set address><Format url_query>5500 Grand Lake Drive, San Antonio, TX</Format></Set>
…then pass it to the link href attribute:
<a href="https://example.com/?query={Get address}">Click here</a>