Sorry for the longish question but I wanted to give as much detail as
possible.
MediaWiki 1.11.1
CentOS 5.1
MySQL 5.0.22-2.2.el5
PHP 5.1.6.15.el5
I'm having trouble building what seems like a fairly simple template.
I've read documentation, I've looked at examples, I've even copied
templates from other sites but it's not working. Any help you can
provide would be greatly appreciated. I have simplified my template to
isolate the problem. So, I have a template called Person-Simple that
looks like this:
<includeonly>{| class="infobox" border="1"
|-
! align="center" colspan="2" border="1"
|'''{{{Name}}}'''
|- {{#if:{{{Sex}}}|
! border="1"{{!}}Sex:
{{!}} {{{Sex}}}
|- {{#if:{{{Birth}}}|
! border="1"{{!}}Birth:
{{!}} {{{Birth}}}
|-
! border="1"|Death:
| {{{Death}}}
|}</includeonly>
This template gets four parameters: Name, Sex, Birth, and Death. Two of
them are (or should be) conditional. That is, if there is no value for
either Sex or Birth, that row should not show up in the table. Death
will show up either way, since I left out the #if statement. In a page,
I have code to call the template as follows:
{{Person-Simple
|Name =John Doe
|Sex =Male
|Birth =
|Death =
}}
Note that neither Birth nor Death have values (there are no spaces after
the equal signs, if that matters). If the template were coded
correctly, this would produce a table with the name spanning two
columns, then two rows, one with "Sex: Male" and another with "Death:
".
However, the Birth row, which shouldn't show up, does.
One thing is that the {{#if: statements do not seem to have closing }}.
I tried adding them, however, and they simply show up on the page.
That's obviously not right, either. Does an {{#if: statement need to be
all on one line? It doesn't seem so. In any case, when I use these
instead of the above, they don't show up whether they have values or
not. Putting the trailing }} on these now seems to have no effect.
|- {{#if:{{{Sex}}}|! border="1"{{!}}Sex: {{!}}{{!}} {{{Sex}}}
|- {{#if:{{{Birth}}}|! border="1"{{!}}Birth: {{!}}{{!}} {{{Birth}}} }}
I also tried copying code from a template on another site. Their lines
look like this:
|-
{{#if:{{{Sex|}}}|
! Sex:
{{!}} {{{Sex}}}}}
|-
{{#if:{{{Birth|}}}|
! Birth:
{{!}} {{{Birth}}}}}
That makes sense to me but when I paste it into my template, it produces
table rows whether there are values or not. In the Sex: row, in the
right hand column, it has "Male}}" while the Birth: row has "}}".
So,
it appears to be printing the closing }} from the {{#if: statement. Not
only that, but outside the table I have:
{{#if:Male| {{#if:|
Note that the related code for Birth does not show up like that. This
template seems to work on the site I took it from
(
http://genealogy.wikia.com/).
I feel like I'm close but I'm pulling my hair out trying to get it
working. Can someone explain what I'm doing wrong? Or, perhaps more to
the point, how to do it right? Thanks for your time.
--
Henry