Extension:UrlGetParameters

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

Release status:Extension status stable

ImplementationTemplate:Extension#type Parser function
DescriptionTemplate:Extension#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)Template:Extension#username S.O.E. Ansems
Latest versionTemplate:Extension#version 1.3.0 (2012-01-19)
MediaWikiTemplate:Extension#mediawiki 1.10.x or higher
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license No license specified
Download
Hooks usedTemplate:Extension#hook
ParserFirstCallInit

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

Check usage and version matrix.

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]

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]

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]

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]

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

Version history[edit]

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