Need some MediaWiki help - evaluation in a template - Printable Version +- Drunkard's Walk Forums (http://www.accessdenied-rms.net/forums) +-- Forum: General (http://www.accessdenied-rms.net/forums/forumdisplay.php?fid=1) +--- Forum: General Chatter (http://www.accessdenied-rms.net/forums/forumdisplay.php?fid=2) +--- Thread: Need some MediaWiki help - evaluation in a template (/showthread.php?tid=14085) |
Need some MediaWiki help - evaluation in a template - robkelk - 03-13-2021 G'day! I can't figure out where on the MediaWiki site to ask for help with coding an evaluation in a template, so I'll start by asking here: First question: Can I evaluate the value of one field based on the contents of a different field? Second question: Can I use wildcards in an evaluation? If yes, what is the syntax of the wildcards? The specific case: I've imported the Wikipedia template "Infobox" to the freebie wiki and have written a template that uses it. Right now, my code for the "image" parameter in the calling template is an if/else check that displays the image if a parameter exists or adds a category if the parameter is blank: |image = {{#if:{{{image|}}} |[[File:{{{image|}}}|250px]] |[[Category:Page Needing Image]]}} I now have a request for a third case check in that line:
The value passed to "data1" will contain some but not all of a URL, one or two template calls, or a comment, with no way to know what order they'll be in. I'm assuming that it's safe to nest "if" statements to create an if/elseif/else check. It's the "elseif" part of this that I'm having trouble with. Any help with coding this evaluation would be appreciated... RE: Need some MediaWiki help - evaluation in a template - Labster - 03-13-2021 Huh, let's see. Elsif is really just syntatic sugar for another if/else block, so that's easy enough. Code: {{{image| Something like this maybe? But you'd need to get support for pos from the admins I think: Quote:All of these functions (len, pos, rpos, sub, replace, explode) are integrated from the StringFunctions extension, but are only available if an administrator sets $wgPFEnableStringFunctions = true; in LocalSettings.php. RE: Need some MediaWiki help - evaluation in a template - robkelk - 03-13-2021 Thanks. Since I'm the founding admin of the freebie wiki, I suspect they'll at least listen to the request if I need to make it. |