This very simple plugin will take an url and modify its query string. The resulting url will preserve all unmodified parameters and respect the chosen permalink mode, so:
<txp:etc_url url="http://my.web.site/section/tag/?q=etc&pg=2" query="pg=3" />
will produce
http://my.web.site/tag/?q=etc&pg=3
in /section/title
mode, and
http://my.web.site/index.php?s=tag&q=etc&pg=3
in messy
mode.
The special txp parameters (id
, s
, etc) will receive a special treatment.
Attributes
- url: url to rewrite, default is the page url.
- context: article, file, image, link or empty. Use
context="article"
rather thanurl='<txp:permlink />'
inside article lists. - query:
&
-separated list of tokenskey
orkey=value
, like this:key1=val1&key2&key3=val3
. Ifval
is not set,key
will be removed from url. - sanitize: comma-separated URL parameters that should be transformed following the same rules as for article titles.
- mode: permlink mode.
- type: URL parameter to extract, default none (the whole URL). If type starts with &, it’s value will be URL-encoded.
Why would you need it?
To link to all articles posted by the current author within the same year and category, you could use
<txp:etc_url url='' query='c=<txp:category1 />&author=<txp:author />&month=<txp:posted format="%Y" />' />link</txp:etc_url>
For more advanced example, see here.
Some Textpattern-specific url variables:
id
: article ids
: sectionc
: categoryauthor
: authors real namemonth
: publication datepg
: current pageq
: search query string
History
Version 0.1: initial release.
Version 0.2: works in all url modes now. Added custom attribute.
Version 0.3: dropped custom, added sanitize and type attributes.
Version 0.4: added mode and context attributes.
File(s)
- File: etc_url.txt [13.76 kB] (1971 downloads, ~14 per month)