The "if" command
this wiki
Forum page
To contact staff directly or to report bugs, please use Special:Contact.
The #if: command. Is there anywhere I can find out how to use this? But if there isn't, I'll keep it short: So, I have a Talk template at a wiki, it involves me to type "{{ILHI|~~~~~|blah blah}}". I want to use the #if: command to add something else. So when I type "{{ILHI|~~~~~|blah blah|additional space}}", it will choose another template with the extra {{{3}}}. So if I were to call the first template "{{Template 1||}}" and the second "{{Template 2|||}}" what would the code be (if it is possible) to choose the template based on if there's three "|"s --I Lion Heart I 19:16, 30 September 2008 (UTC)
- Your third parameter will require at least one wikipedia:character (computing), and it probably needs to be a non-wikipedia:whitespace (computer science) character (i.e., not a spacebar or Enter character).
{{#if: {{{3|}}}
| value if true (non-empty)
| value if false (empty)
}}
- Place that anywhere (multiple places if necessary) in your code. If the third parameter was not passed, an empty value is used in its place. --Jesdisciple (talk) 20:30, 30 September 2008 (UTC)
- Thanks. --I Lion Heart I 17:02, 1 October 2008 (UTC)
Need help
I'm trying to code something, yet it just won't work. Can someone look at the code here, see what I am trying to do, and tell me why it doesn't work/ if it can ever work. --I Lion Heart I 19:56, 14 October 2008 (UTC)
- I've copied the template over here in User:TulipVorlax/ILHI.
| VA | VB | VC | VD | VE |
|---|
- So you're trying to have a table with variable number of row with a variable number of columns ? — TulipVorlax 21:13, 14 October 2008 (UTC)
- That is the gist of it. It's a template which could be used for anything. In actual fact it's for versions of games with more than one translations (going across the rows). And then columns for multiple related pages. I'm trying to code so only one template is used for all different games. --I Lion Heart I 17:58, 15 October 2008 (UTC)
- In this perticular case, maybe the HTML format of tables would work better. I'll try it if you want when i'll have more time... — TulipVorlax 18:08, 15 October 2008 (UTC)
- Please. --I Lion Heart I 18:14, 15 October 2008 (UTC)
| col 1 | col 2 |
|---|---|
| cell 1 | cell 2 |
| cell 3 | cell 4 |
| col 1 | col 2 | col 3 | col 4 |
|---|---|---|---|
| cell 1 | cell 2 | ||
| cell 3 | cell 4 |
| col 1 | col 2 | col 3 |
|---|---|---|
| cell 1 | cell 2 | |
| cell 3 | ||
| last cell |
With User:TulipVorlax/ILHI2 you can have 5 columns and 3 rows. First two columns allways show but only header if no value is specified for the rows. — TulipVorlax 06:16, 17 October 2008 (UTC)
- Hum, it makes a weird effect now. Maybe you might be able to fix a thing. I'll lookit up too. — TulipVorlax 06:20, 17 October 2008 (UTC)
- GOT IT ! Lol. Looking at the source of the page, there was <p><br /> </p> at many place in the tables. So i've placed the code on a single line. It's not as easy to work with it's internal code now but it render correctly.
- By the way, i did not kept the same names as you for the parameters. I never begin parameter names with a number (not sure why). — TulipVorlax 06:37, 17 October 2008 (UTC)
- You have my thanks. Cheers. :D --I Lion Heart I 15:45, 17 October 2008 (UTC)
- Hang-on; is there any additional code the wiki needs for it to work? The same thing happens as with my original failed version as with this. --I Lion Heart I 16:08, 17 October 2008 (UTC)
- There are other ways to do this as well, more flexible (and legible) ones, but to decide what is best I need more information on how this is supposed to work and why you choose to use a template and not a wikitable. Do you have a link to an example table for me, or a page that already has the information that you want to have tabularized? --◄mendel► 10:58, 18 October 2008 (UTC)
- this page uses the basic template I tried to expand from -- as this is the style table we use everywhere. Then one admin said "Wouldn't it be cool if we good get it to work like a template", and then I said, "This is possible using the "#if:" command", and then another admin said "Make a sandbox version so we can have one template for all games". And here I am. I Lion Heart I 14:24, 18 October 2008 (UTC)
- Ok, Lion Heart, thanks for the clarification. If I understand your needs correctly, what you want the template to do is to color the header white on blue and maybe set the table parameters. This seems to me to be most easily achieved with some CSS, you'd start the table
{| class="blueheader"and put some code in MediaWiki:common.css (such as.blueheader th { background:blue; color:white; }) and then you get the full flexibility and familiarity of regular wiki tables without the hassle of adding the formatting for the white on blue to every title item. Every template solution I could come up with is more complicated without any added gain. --◄mendel► 22:00, 22 October 2008 (UTC)
- Ok, Lion Heart, thanks for the clarification. If I understand your needs correctly, what you want the template to do is to color the header white on blue and maybe set the table parameters. This seems to me to be most easily achieved with some CSS, you'd start the table