5

I want to pass an URL to my Mediawiki template as a parameter, but if it contains =, it treats the URL as a named parameter. Therefore, the following does not find and replace the template parameter {{{1}}}:

{{MyUrl|http://www.example.com/abstract.cfm?uri=aa-123456}}

Escaping = with %3D leads to problems of passing the link in the browser (Chrome) — the server responds with 404.

Also, installing extensions on this Mediawiki server is not recommended. Can this be done in Vanilla Mediawiki?

3

The workarounds:

Explicitly preceed the argument with the (numerical) parameter name in the call to template, like this:

{MyUrl|1=http://www.example.com/abstract.cfm?uri=aa-123456}}

Another solution: one can create a symbolic name for the parameter. Then the template may look something like this:

See here: [{{{link}}} (link)]

And the call like this:

{MyUrl|link=http://www.example.com/abstract.cfm?uri=aa-123456}}

Combine the solutions to accept both named and ordered parameters for when there is no '=' sign there. The template (notice the empty string after '|' as a default value so that only one parameter is used):

See here: [{{{link|}}}{{{1|}}} (link)]

This can be used with the call using 'link' above and also like this:

{MyUrl|http://www.example.com/no/equal/signs/}}

Note, that the "combined" approach is not recommended due to inconsistency in parameter usage, unless there are too many calls across the wiki to the template using the ordered parameters, making it impractical to change all calls to the named parameter approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.