Mobile app version of vmapp.org
Login or Join
Heady270

: In MediaWiki templates how to show empty default value In a MediaWiki template I'm making, I want to let it to become [[CODE-value]] when CODE=value is used and empty when CODE=value is not

@Heady270

Posted in: #Mediawiki #Template

In a MediaWiki template I'm making, I want to let it to become [[CODE-value]] when CODE=value is used and empty when CODE=value is not given in the actual page. The current version

[[CODE-{{{CODE|}}}|{{{CODE|}}}]]


fails the second requirement. Any ideas?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Heady270

1 Comments

Sorted by latest first Latest Oldest Best

 

@Annie201

Make sure the ParserFunctions extension is installed.

Then put the following in a template, such as Template:Iftest

{{#if: {{{CODE|}}} | [[CODE-{{{CODE}}}]] | (not applicable) }}


If CODE-parameter is empty or not present you get (not applicable). i.e.


{{Iftest|CODE=123}} gives [[CODE-123]]
{{Iftest|CODE=}} gives (not applicable)
{{Iftest}} gives (not applicable)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme