Virgil Ierubino wrote:
<...> you don't have to enclose strings in "quotes". If you want to compare a string to an empty string, you'd use {{#ifeq: {{{1}}} | | then | else }} (i.e. literally put an empty string). Your version had it comparing to a pair of literal double quotes.
Another thing to note is that if {{{1}}} is unspecified (i.e. there is no first parameter) then it comes out as a literal "{{{1}}}" i.e. not empty.
What you need is a default for the parameter, defined by a string after a pipe. So {{{1|hello}}} would return "hello" if {{{1}}} was not specified, otherwise it would return whatever was specified.
In your case, you need the parameter to return nothing if unspecified, so you want to use {{{1|}}} (i.e. an empty default).
Your code looks like it would work with these changes.
Yes, it works like a charm! Thank you very much.
The final code (expanding the link with up to five parameters) , fixed according your instructions above:
{{ #ifexist:Image:{{{1|}}} | {{ #ifeq:{{{2|}}} || [[Image:{{{1}}}]] | {{ #ifeq:{{{3|}}} || [[Image:{{{1}}}|{{{2}}}]] | {{ #ifeq:{{{4|}}} || [[Image:{{{1}}}|{{{2}}}|{{{3}}}]] | {{ #ifeq:{{{5|}}} || [[Image:{{{1}}}|{{{2}}}|{{{3}}}|{{{4}}}]] | [[Image:{{{1}}}|{{{2}}}|{{{3}}}|{{{4}}}|{{{5}}}]] }} }} }} }} | [[Category:Missing image|{{{1}}}]] }}
Regards,
// Rolf Lampa
On 03/04/07, Rolf Lampa rolf.lampa@rilnet.com wrote:
Hi all,
I'm making a template attempting to get ParserFunctions to determine assigned parameters for me, but it seems like I can't nest multiple #ifeq-functions.
Imagine the template {{pseudoimage}}, it should be able to properly handle multiple params:
{{pseudoimage|image name.jpg}} {{pseudoimage|image name.jpg|thumb}} {{pseudoimage|image name.jpg|thumb|65px}} {{pseudoimage|image name.jpg|thumb|65px|left}} {{pseudoimage|image name.jpg|thumb|65px|left|Well, descriptive text}}
The first case to test is easy, and it works:
Test 1: {{{1}}} = image name:
{{#ifexist:[[Image:{{{1}}}]]|[[Image:{{{1}}}]]|[[Category:Image missing]]}}
Test 2: ( same as above, plus checking for SECOND param - works )
{{#ifexist:[[Image:{{{1}}}]]| {{#ifeq:{{{2}}}|""|[[Image:{{{1}}}]]|[[Image:{{{1}}}|{{{2}}}]]}} |[[Category:Image missing]]}}
Test 3: ( same as above, plus checking for THIRD param - does NOT work)
{{ #ifexist:Image:{{{1}}} | {{ #ifeq:{{{2}}} | "" | [[Image:{{{1}}}]] | {{ #ifeq:{{{3}}} | "" | [[Image:{{{1}}}|{{{2}}}]] | [[Image:{{{1}}}|{{{2}}}|{{{3}}}]] }} }} | [[Category:Image missing]] }}
So now, how can I achieve something like this. I need to check at least five parameters (I think). Any ideas of other ways to achieve the same goal?
Regards,
// Rolf Lampa
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/mediawiki-l