Pergunta

So I've been trying to implement an #if parser into an infobox, but I seem to be out of luck. The previous code I used seems to be outdated, and I can't find the a way to code it in again, differentely. :/

Basically, in this infobox, if a field is not typed in(or if typed in is left empty) it should become 'invisible' or not even render.

This code worked fine in a previous version of MediaWiki(not sure which one though), but no longer: http://pastebin.com/uQ49mPbQ. I've been trying to use it as a tutorial, and even outright copy and pasted it, but it simply doesn't work. All of the fields would become invisible, regardless of what I would have done to them...

This is the new code that I am using, and would like to be #if'ed: http://pastebin.com/3j0AbN5v

Any help would be welcome.

Foi útil?

Solução

You need to enable the ParserFunctions extension to be able to use the {{#if}} parser function. Do this in your LocalSettings.php:

require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );

If you want to use the string functions (like {{#replace}}, {{#explode}}, etc), also add:

$wgPFEnableStringFunctions = true;

In recent versions of MediaWiki, ParserFunctions is included (but not enabled) so you don't need to download anything.


Basic troubleshooting: Whenever you see code like {{#zyx:...}} in a wiki page, it (probably) means, that someone tried to use a parser function that is not installed. Unless there is a parser function called “zyx” installed, the code {{#zyx:...}} has no special meaning to the wiki, and the text will be printed just like it is. The most common parser functions are collected in an extension called ParserFunctions, that is used on WikiMedia wikis. You will need the parser functions from ParserFunctions whenever copying templates from e.g. English Wikipedia.

To see what parser functions you have enabled, navigate to Special:Version on your wiki. Below the list of installed extensions is a list of tags (such as <gallery />) and parser functions available. As you can see, “if” is among the parser functions on your old wiki, but not on your new.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top