[Mediawiki-l] Template parameters don't work extensions

Sheldon Rampton sheldon at prwatch.org
Sun Feb 12 09:23:28 UTC 2006

I'd like to be able to write a MediaWiki extension that uses template  
parameters, but the parser doesn't seem able to handle this.

As an example, let's say that I set up a page [[Template:Politician]]  
that creates an external link to some information about a U.S.  
congressional district.

I would invoke this template as follows:
{{Politician |
   name = John Doe |

The text of the template itself, which generates the link, is as  

*[http://www.politician.com?district={{{district}}} District  
information for {{{name}}}]

If, however, the "district" parameter is omitted, I wouldn't want  
this line to be created at all. There's a messy way to set up if-then  
decisions using existing template mechanisms, but I'd rather be able  
to use something like the following as the text of the template:


Then I could write a MediaWiki extension that handles the logical  
branching. The extension could also handle some other processing,  
such as pulling in summary data about that congressional district  
from an another website's external APIs.

At present, however, there doesn't seem to be any way to pass the  
{{{name}}} and {{{district}}} parameters into a MediaWiki extension.  
Instead of getting the VALUES of those parameters, I just get the  
string "{{{name}}}" and "{{{district}}}".

Solutions, anyone?

--Sheldon Rampton

More information about the MediaWiki-l mailing list