Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some MediaWiki help - evaluation in a template
Need some MediaWiki help - evaluation in a template
#1
Question 
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:
  1. if no value is passed to "image", display nothing and add the category "Page Needing Image" to the page, exactly as above;
  2. elseif a value is passed to "image" and a value that contains a call to a template named "unavailable" is passed to "data1", display the file with a gray background;
  3. else, display the file with the default background, exactly as above.

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...
--
Rob Kelk

Sticks and stones can break your bones,
But words can break your heart.
- unknown
Reply


Messages In This Thread
Need some MediaWiki help - evaluation in a template - by robkelk - 03-13-2021, 12:58 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)