I didn't read all of your example, but there are a few things I can see
wrong already:
#ifeq doesn't work like an If function in something like Visual Basic, or
other programming languages. For a start, 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.
On 03/04/07, Rolf Lampa <rolf.lampa(a)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(a)lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l