Extension:UrlGetParameters

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
UrlGetParameters

Release status: stable

Implementation Parser function
Description Provides a parserfunction {{#urlget:...}} which allows access to the url parameters in your page.

Note Note:Caching for the page you use this extension on should be disabled.

Author(s) S.O.E. Ansems
Latest version 1.3.0 (2012-01-19)
MediaWiki 1.10.x or higher
Database changes No
License No license specified
Download
Hooks used
ParserFirstCallInit

Translate the UrlGetParameters extension if it is available at translatewiki.net

Check usage and version matrix; code metrics

This extension enables you to use and/or display the "GET" parameters of the URL, i.e. the query string, on the wiki page.

Download[edit | edit source]

You can download the code, in .tgz format, here.

You can also download the code directly via Git from the MediaWiki source code repository. From a command line, call the following:

git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UrlGetParameters.git

To view the code online, including version history for each file, go here.

Installation[edit | edit source]

Once you have downloaded the extension, enable it by adding this line to your LocalSettings.php:

require_once( "$IP/extensions/UrlGetParameters/UrlGetParameters.php" );

Usage[edit | edit source]

To display the value of a URL get parameter in your page, you might do this:

{{#urlget:parameter-name}}

Where parameter-name is the name of the parameter whose value you want. If the parameter is not found, the extension will result in nothing. Alternatively, you can also specify a default value as follows:

{{#urlget:parameter-name|default-value}}

When the parameter parameter-name is not available, then the value default-value is returned.

If the URL contains parameters of the form "A[B]=C", you can display the value "C" in a similar way, by calling:

{{#urlget:A[B]}}

Authors[edit | edit source]

This extension was written by S.O.E. Ansems. Important contributions were made by Ankit Garg and some anonymous editors.

Version history[edit | edit source]

Version Date Changes
1.0 February 21, 2008
  • Initial version
1.1 February 15, 2011
  • Page caching disabled
  • Handling added for array parameters
  • Security fix added using rawurlencode()
1.2 March 2, 2011
  • Code tidy up
  • Improve hook calls