Extension:GetParam

From MediaWiki.org

Jump to: navigation, search

     

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
getParam

Release status: beta

Implementation  Parser function
Description to get variables from the URL parameters
Last Version  0.1
License GNU
Download no link

check usage (experimental)

Contents

[edit] What can this extension do?

This extension can get the parameters in URL.
It can be useful to translate templates, or obtain more dinamic templates.

[edit] Usage

{{#getParam:param}}

[edit] Download instructions

Please cut and paste the code found below and place it in $IP/extensions/getParam/getParam.php.
Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

[edit] Installation

To install this extension, add the following to LocalSettings.php:

#add configuration parameters here
#setup user rights here
require_once("$IP/extensions/getParam/getParam.php");

[edit] Code

<?php
 
# Define a setup function
$wgExtensionFunctions[] = 'efGetParam_Setup';
# Add a hook to initialise the magic word
$wgHooks['LanguageGetMagic'][] = 'efGetParam_Magic';
 
function efGetParam_Setup()
{
    global $wgParser;
    # Set a function hook associating the "getParam" magic word with our function
    $wgParser->setFunctionHook( 'getParam', 'efGetParam_Render' );
}
 
function efGetParam_Magic( &$magicWords, $langCode )
{
    $magicWords['getParam'] = array( 0, 'getParam' );
    return true;
}
 
function efGetParam_Render( &$parser, $param = '' )
{
    global $wgRequest;
    return $wgRequest->getVal( $param );
}