I defined a template that should link to a page when the the variable is non-empty:

[http://openlibrary.org/works/XXX/{{{ISBN}}} {{{ISBN|}}}]

But what's not working as perfectly is that when the variable ISBN is not given a value, a non-functional link is still displayed. How to improve this?

1 Answer 1


Assuming you have the ParserFunctions extension, you can use the #if function, as documented on MediaWiki:

This function evaluates a test string and determines whether or not it is empty. A test string containing only white space is considered to be empty.

{{#if: test string | value if test string is not empty | value if test string is empty (or only white space) }}

The template you described would look something like this, that is, the link is only displayed if the ISBN parameter is not empty:

{{#if: {{{ISBN|}}} | [http://openlibrary.org/works/XXX/{{{ISBN}}} {{{ISBN|}}}] }}

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.