Help talk:Conditional tables
This help page does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||||||
|
MUST use HTML
edit- Actually, you MUST use HTML to hide rows with Qif, because otherwise the pipes of the table syntax conflicts with those of the template syntax.
- You'll want to reference the Boolean templates too
Circeus 14:07, 17 March 2006 (UTC)
- For some reason I thought it might work with the table syntax if you used sub templates, like this–
- Template:Foo
{| class="infobox" {{qif|test={{{var|}}}|then={{Foo/Bar|{{{var|}}}}}}} |- ! Baz | {{{var2}}} |}
- Template:Foo/Bar
|- ! Foo | {{{var}}}
- At least that was an exception that I thought worked. =) Regarding boolean templates, I have very little experience with those. If you think you can write up a basic beginners guide, be my guest. =) If not, I'll try and add that as I learn about them. —Locke Cole • t • c 16:14, 17 March 2006 (UTC)
- I tried to understand Template:Boolexists(edit talk links history) because I don't like {{Qif}} and want a simpler {{ifdef|test|do}}, but so far that failed. Some test results on Template talk:Boolexists, note that these tests have nothing to do with the purpose of this template, i.e. test if a page exists. Omniplex 14:08, 19 March 2006 (UTC)
- The point MUST use HTML turned out to be wrong, see below and Template:!(edit talk links history), it's more like MAY use XHTML. Omniplex 11:20, 21 March 2006 (UTC)
New attempt
edit- Note: most of the templates referred to in this discussion have since been repurposed for other tasks. Happy‑melon 13:17, 26 September 2008 (UTC)
Mixing XHTML with Wiki table syntax is a layer violation, and some uses in (edit talk links history) for the shortcut are incorrect, missing <tr> and similar issues, in other words FUBAR.
But it should be possible to get it to work somehow with Wiki syntax.
{| class="infobox" {{qif|test={{{foo|}}}|then= {{!}}- ! Foo {{!}} {{{foo}}} }} |- ! Bar | {{{bar}}} |}
Apparently that works, we need a shorter name for
the template returning a vertical bar... ;-) Omniplex 13:57, 19 March 2006 (UTC)
{| class="infobox" {{qif|test={{{foo|}}}|then= {{Lowercase}} ! Foo {{TD}} {{{foo}}} }} |- ! Bar | {{{bar}}} |}
- Which ain't pretty, but might be better than pure (X)HTML. Regarding the header templates, I only looked at one I admit, but it looked like it was just defining another column in the already existing row (so no need for
<tr> ... </tr>
). The one thing I saw that did kind of bug me was the nesting of<th>
within<td>
. —Locke Cole • t • c 21:01, 19 March 2006 (UTC)
- Yes, at the time when you inserted it I had no clue what it's supposed to do, i.e. avoid the reserved "|" within Qif. A dummy template with output "|" might be cleaner. We don't need <th>, "!" is okay. Maybe a second dummy template for "||", but actually I'd say one is bad enough, and "||" is never required. Omniplex 21:55, 19 March 2006 (UTC)
- I've trimmed my old comment with <s> reflecting Locke's comment and replaced {{tl2}} by {{tlp}} in the sample table. Omniplex 10:01, 21 March 2006 (UTC)
- Well, if you just want to make a template for the vertical bar, I note that {{B}} and {{V}} are available. (B for bar, V for vertical-bar?). I know AzaToth prefers (and I somewhat agree) using straight (X)HTML for table syntax (in other words, no wiki-markup at all). I don't know that using a sub-template to get the bar would be any better or worse from a code-readability point of view though... I'm leaning towards worse, but I need to look at it more. HTML table syntax isn't that complicated though (really just five tags that people would need to know; TABLE, TR, TD, TH, and CAPTION). And the mix of HTML and {{qif}} can be neatly separated.
- 2008 update: {{B}} is no longer available. — SMcCandlish [talk] [cont] ‹(-¿-)› 15:30, 30 August 2008 (UTC)
- By all means though you should edit this in as another alternative if you think it'd be more readable. =) —Locke Cole • t • c 22:10, 19 March 2006 (UTC)
- Well, if you just want to make a template for the vertical bar, I note that {{B}} and {{V}} are available. (B for bar, V for vertical-bar?). I know AzaToth prefers (and I somewhat agree) using straight (X)HTML for table syntax (in other words, no wiki-markup at all). I don't know that using a sub-template to get the bar would be any better or worse from a code-readability point of view though... I'm leaning towards worse, but I need to look at it more. HTML table syntax isn't that complicated though (really just five tags that people would need to know; TABLE, TR, TD, TH, and CAPTION). And the mix of HTML and {{qif}} can be neatly separated.
- Such a solution risk making styling these cells hell. What's so bad with XHTML in there?. Circeus 22:07, 20 March 2006 (UTC)
- If what you need is say
| style="color: red" | something red
- you could use
{{!}} style="color: red" {{!}} something red
- As straight forward as possible. Omniplex 22:31, 20 March 2006 (UTC)
- If what you need is say
- You said AzaToth prefers (and I somewhat agree) using straight (X)HTML for table syntax (in other words, no wiki-markup at all). While I disagree strongly in the case of layer violations (either use Wiki or XHTML table syntax, but don't mix them) XHTML syntax and exclamation mark are no issues wrt {{Qif}}, only the vertical bar has to be escaped from the parameter default mechanism. Normally | is good enough, but within a table it needs a template. I've created Template:!(edit talk links history) for this purpose. Omniplex 22:20, 20 March 2006 (UTC)
Not really necessary to invent a third method, but I'm interested to get some ideas about its fragility:
{| class="infobox" {{ifdef|{{{foo|}}}| {{!}}- ! Foo {{!}} {{{foo}}}}} |- ! Bar | {{{bar}}} |}
The code above is in {{qif_example_2/b}}. The table below demonstrates the effect when it's used:
Template call | Result |
---|---|
{{qif_example_2/b}}
|
{{qif_example_2/b}} |
{{qif_example_2/b|foo=}}
|
{{qif_example_2/b|foo=}} |
{{qif_example_2/b|foo=|bar=vbar}}
|
{{qif_example_2/b|foo=|bar=vbar}} |
{{qif_example_2/b|foo=value}}
|
{{qif_example_2/b|foo=value}} |
{{qif_example_2/b|foo=value|bar=vbar}}
|
{{qif_example_2/b|foo=value|bar=vbar}} |
So far apparently fine, but it didn't work with at least one of the Wikipedia header templates.
The Template:Ifdef(edit talk links history) code is straight from Meta. It's the {{Qif}} version without else replacing the remaining named parameters test and then by positional parameters 1 and 2 resp.
Please don't try to fix it, I want it as simple as is, but it makes me nervous that I don't understand why it's so fragile. -- Omniplex 16:17, 27 March 2006 (UTC)
Answered by Paddu in Ifdef, executive summary: Use {{ifdef|test|2=then}}
if then contains any "=". Minimalism has its drawbacks. -- Omniplex 22:15, 17 April 2006 (UTC)
TfD nomination of Template:Ifdef
editTemplate:Ifdef has been nominated for deletion. You are invited to comment on the discussion at the template's entry on the Templates for Deletion page. Thank you. -- Omniplex 15:15, 18 April 2006 (UTC)
Direct ifdef approach
editAfter some drawbacks with #if:
and Ifdef have been identified
(and for the latter documented) it's time to check out
the m:Help:Parameter default mechanism directly
with no if-construct at all as in the upgraded
{{Shortcut|[[WP:QIF]]}}
:
{| class="infobox" {{{foo{{{foo|}}}| {{!}}- ! Foo {{!}} {{{foo}}}}}} |- ! Bar | {{{bar}}} |}
The code above is in {{qif_example_2b}}. The table below demonstrates the effect when it's used:
Template call | Result |
---|---|
{{qif_example_2b}}
|
{{qif_example_2b}} |
{{qif_example_2b|foo=}}
|
{{qif_example_2b|foo=}} |
{{qif_example_2b|foo=|bar=vbar}}
|
{{qif_example_2b|foo=|bar=vbar}} |
{{qif_example_2b|foo=value}}
|
{{qif_example_2b|foo=value}} |
{{qif_example_2b|foo=value|bar=vbar}}
|
{{qif_example_2b|foo=value|bar=vbar}} |
An expected minor difference in the first line, otherwise it works. This method is now documented in Advanced_templates on Meta.
There are apparently some drawbacks with substituting templates containing many ifdef-constructs, it replaces pointless code for ifndef cases. -- Omniplex 01:58, 22 April 2006 (UTC)
- Putting the basic logic behind 'qif' and 'switch' directly into the final template like this has been called 'Weeble code' or the 'blank parameter trick' in the past. Examples previously in widespread use can be seen here and here. The general drawback of the method is the need to deliberately set a parameter value to 'blank' (as opposed to unset) so that it may act as a switch. Users calling the template will often assume that a parameter set blank is the same as an unset parameter and exclude it... thereby deactivating the conditional feature. This isn't a problem if the blank parameter is set by a template which then calls another template, but then the anti 'meta-template' jihadists take up arms. Ergo... m:ParserFunctions was developed. --CBDunkerson 08:08, 22 April 2006 (UTC)
New twist in the mediazilla:5678 saga, it breaks after substitutions. If I'd want to do something with {{{1|default}}} and need no "else" code, then I'd use the old mechanism, it's harder to destroy it. -- Omniplex 05:34, 16 May 2006 (UTC)
Interwiki link to vi:
edit- Note to admin handling this: Template talk:! redirects here (which is fine), hence why the request for modification is here and not there.
Please add an interwiki link at Template:! to the Vietnamese version of that template:
[[vi:Tiêu bản:!]]
Thanks.
– Minh Nguyễn (talk, contribs) 19:50, 8 April 2006 (UTC)
- Done. --CBDunkerson 20:36, 8 April 2006 (UTC)
- My bad, I didn't expect a protection when I redirected it. -- Omniplex 20:50, 8 April 2006 (UTC)
Ok, so we have built-in conditionals (per header) on a trial basis. Unfortunately, they work nearly the same as QIF except for a few issues;
- The '#if:' feature does not use 'parameter names'. So, '|test=<condition>|then=<text if true>|else=<text if false>' becomes just '|<condition>|<text if true>|<text if false>'. Overall I think the shorter format is better - though it requires that a user know the order of the parameters rather than being able to set them in any order.
- For 'QIF' a '|test=0' condition resolved to 'test exists' and was therefor 'TRUE'. For '#if:' a condition of '0' resolves to 'FALSE'. Again, I think this is an improvement overall. It may change the behaviour of a few templates, but it simplifies the use of conditions based on mathematical and boolean logic.
- Finally, #if: seems to have a problem with line breaks that can be somewhat confusing;
This works as expected; |- valign=top {{#if:{{{param|}}}| {{!}} Parameter: {{!}} {{{param}}}}} This does not; |- valign=top {{#if:{{{param|}}}| {{!}} Parameter: {{!}} {{{parameter}}}}}
Essentially, #if: ignores the line break after the condition and the second scenario above resolves as;
|- valign=top | Parameter: | <value of {{{parameter}}}>
Obviously that isn't proper table markup and thus the 'Parameter:' just is not displayed. This is easy enough to resolve by placing the '{{#if:' on a new line, but it is an additional limitation compared to 'QIF'.
Other than those issues I think #if: and QIF are essentially identical in function. You can use HTML tags (i.e. <tr>, <th>, <td>) or the {{!}} template trick - provided you keep the line-break issue in mind, but not direct '|' table markup. It accepts '|' in wiki-links like QIF. Less than we might have hoped for, but I think a viable replacement... and the other new features (expr: & rand:) are wonderful. The #ifeq is similar to the 'booleq' template, but I'll have to do more testing - I suspect it has the same sort of minor quirks as '#if:' vs 'qif'. --CBDunkerson 11:38, 13 April 2006 (UTC)
- Something tells me the bit with #if treating "0" as false will bite us more than help us. See my suggestion on m:ParserFunctions for a #ifexpr. If that were implemented, I think #if should be modified to be a simple empty/non-empty test. Or would there still be a good reason for the true/false test? —Locke Cole • t • c 12:10, 13 April 2006 (UTC)
- Stuff written by me now documented in mediazilla:5569 removed here, the <pre> bugs are unrelated to
{{Qif}}
and #if; oddities. -- Omniplex 22:23, 17 April 2006 (UTC)
Updated instructions
editI've updated the instructions to use #if
instead of {{qif}}. The only loose-end that remains is updating {{Infobox}} (which is still referenced in these docs) and deciding upon a new name for this page. Originally I planned on moving this to Wikipedia:If conditionals, but maybe Wikipedia:ParserFunctions conditionals would be more appropriate (and would allow for later expansion to include examples using #ifeq
, #ifexpr
and so forth)? Or perhaps a more generic name, like Wikipedia:Template conditionals? Comments welcome, also, if anyone notices anything I missed in the article, please correct. =) —Locke Cole • t • c 05:47, 17 April 2006 (UTC)
- I've added a caveat about "=" and positional parameters. Where
{{ifdef}}
works (no else needed) it's unnecessary to replace it by #if: (and v.v.). Renaming is tricky, what about all its links and the shortcut? -- Omniplex 23:25, 17 April 2006 (UTC)- The only trouble with renaming this page is handling any double redirects that crop up. I don't think there'll be many though. =) Redirects from here to whatever new name is chosen will handle the rest. —Locke Cole • t • c 16:27, 18 April 2006 (UTC)
- Double redirects are shown, but what about dozens of [[w:Wikipedia:Qif conditionals]] on Meta? Maybe I even used [[w:WP:QIF]] or similar there. -- Omniplex 00:47, 22 April 2006 (UTC)
- As WP:QIF would be changed to point to the new name (and Wikipedia:Qif conditionals would also point to the new name) it shouldn't matter. —Locke Cole • t • c 01:00, 22 April 2006 (UTC)
- Double redirects are shown, but what about dozens of [[w:Wikipedia:Qif conditionals]] on Meta? Maybe I even used [[w:WP:QIF]] or similar there. -- Omniplex 00:47, 22 April 2006 (UTC)
- The only trouble with renaming this page is handling any double redirects that crop up. I don't think there'll be many though. =) Redirects from here to whatever new name is chosen will handle the rest. —Locke Cole • t • c 16:27, 18 April 2006 (UTC)
#if: 5678 watch
editA condensed variant of the table posted on Talk:ParserFunctions, see also mediazilla:5678. Test cases for the "else" anomaly clobbering the second parameter and comparisons with ifdef and ifndef added, subst test case removed (known to fail with ifndef or qif). The problem is fixed if 2nd and 3rd coloumn show roughly the same result.
#if: table
editCode | Result | ifdef |
---|---|---|
{{#if: {{{tst}}} | -1- {{{1}}} }} |
-1- {{{1}}} | {{ifdef | {{{tst}}} | -1- {{{1}}} }} |
{{#if: {{{tst}}} | -2- {{{1|default}}} }} |
-2- default | {{ifdef | {{{tst}}} | -2- {{{1|default}}} }} |
{{#if: {{{tst}}} | -3- {{{2}}} | '''err''' }} |
-3- {{{2}}} | {{ifdef | {{{tst}}} | -3- {{{2}}} | *** }} |
{{#if: {{{tst}}} | -4- {{{2}}} }} |
-4- {{{2}}} | {{ifdef | {{{tst}}} | -4- {{{2}}} }} |
#if: else {{{2}}} anomaly
editCode | Result | ifndef |
---|---|---|
{{#if: {{ns:0}} |n/a| -1- {{{2}}} }} |
-1- {{{2}}} | {{ifndef |{{ns:0}}| -1- {{{2}}} }} |
{{#if: {{ns:0}} |n/a| -2- {{{2|default}}} }} |
-2- default | {{ifndef |{{ns:0}}| -2- {{{2|default}}} }} |
{{#if: {{ns:0}} |n/a| -3- {{{1}}} }} |
-3- {{{1}}} | {{ifndef |{{ns:0}}| -3- {{{1}}} }} |
{{#if: {{ns:0}} |n/a| -4- {{{3}}} }} |
-4- {{{3}}} | {{ifndef |{{ns:0}}| -4- {{{3}}} }} |
-- Omniplex 00:28, 28 April 2006 (UTC)
- You might want to look at http://test.wiki.x.io/wiki/ParserFunctions and see if the examples there cover the cases you're concerned with. —Locke Cole • t • c 01:13, 28 April 2006 (UTC)
- The "Special:Captcha" inline PNGs don't work for me, I only have a Meta-account because Pathoschild created it for me. The backlink at mediazilla:5678 should do it. -- Omniplex 00:38, 1 May 2006 (UTC)
Use with table formating
editI've looked for a way to include formating into a table using #if: I've tryed HTML Table Coding for adding a background colour/image, and i just get the code showing up. And Since i can't use the "|" I can't get Table to have colour or anything else like that.
{{#if: {{{Date of Retirement|}}}|{{{ ! colspan="3" style="border:1px solid #a3bfb1; background:#cef2e0;" | Date of Set [[Retirement]] : | style="border:1px solid #a3bfb1; background:#f5fffa;"|{{{Date of Retirement}}} | }}
The above shows:
{{#if: {{{Date of Retirement|}}}|{{{ ! colspan="3" style="border:1px solid #a3bfb1; background:#cef2e0;" | Date of Set [[Retirement]] : | style="border:1px solid #a3bfb1; background:#f5fffa;"|{{{Date of Retirement}}} | }}
But that has the "|" for wiki tables, so I make them into the
<td><tr><th>
ones.
{{#if: {{{Date of Retirement|}}}|{{{ <th colspan="3" style="border:1px solid #a3bfb1; background:#cef2e0;"> Date of Set [[Retirement]] :</th> <td style="border:1px solid #a3bfb1; background:#f5fffa;">{{{Date of Retirement}}}</td> | }}
That shows this: {{#if: |{{{
Date of Set Retirement : | {{{Date of Retirement}}} |
---|
| }}
Could anyone help me with this? I should also mention, I am New at this.
- The standard way around this problem is to use {{!}}... this is a template which contains nothing but a '|' character. It is left as a template for the evaluation of the #if:, but then after the conditional logic the | is transcluded in and used normally for table logic. There were a few other issues with the examples (extraneous brackets, no table open/close, blank parameter and thus evaluating to nothing, et cetera) which I adjusted as follows;
{{#if: {{{Date of Retirement|Date}}}| {{{!}} ! colspan="3" style="border:1px solid #a3bfb1; background:#cef2e0;" {{!}} Date of Set [[Retirement]] : {{!}} style="border:1px solid #a3bfb1; background:#f5fffa;"{{!}}{{{Date of Retirement|Date}}} {{!}}}| }}
Shows:
Date of Set Retirement : | Date |
---|
— Preceding unsigned comment added by CBDunkerson (talk • contribs) 6:52, 3 September 2006 (UTC)
Logical and/or question
editI have a question I'm hoping someone can help with. Is there any way to do boolean and/or with parameters and #if, short of using nested if blocks? For instance,
{{#if:{{{param1|}}} or {{{param2|}}}|then case|else case}}
Any help would be much appreciated. — George Saliba [talk] 20:40, 5 December 2006 (UTC)
- Nevermind, I figured it out. For or at least you just do {{#if:{{{param1|}}}{{{param2|}}}|then case... — George Saliba [talk] 10:50, 6 December 2006 (UTC)
- Has anyone figured out how to do a logical AND? Please mention it on my talk page if you do. Hypertall (talk) 21:59, 6 May 2012 (UTC)
- It's more complicated, but possible:
{{#ifeq:{{#if:{{{param1|}}}|true|false}}{{#if:{{{param2|}}}|true|false}}|truetrue|Both parameters are present and non-blank|One or both parameters are blank or absent}}
- --Redrose64 (talk) 23:05, 6 May 2012 (UTC)
- Has anyone figured out how to do a logical AND? Please mention it on my talk page if you do. Hypertall (talk) 21:59, 6 May 2012 (UTC)
Help with conditionals with specific variables and if/then
editI am working on a template User:Andrew c/New Testament manuscripts. Instead of forcing the user to format numbers in a specific way, I would like the template to automatically code the numbers based on what class they imput. For example, if the class is set to "papyrus" the number function gets put into a superscript. If the class is set to "Uncial", the number gets bolded. If the class is a lectionary, the number gets italicized. You can look through the history to see the sort of things I have tried out. My problem is I don't know how to get the if to recognize a user inputted variable, and I do not know how to combine multiple conditionals. Any help would be greatly appreciated. Thanks.-Andrew c 18:30, 11 May 2007 (UTC)
Requested move
editWikipedia:Conditional display of table rows makes much more sense, since... er, that's what it's about. (Still not sure what a "qif" is when it's at home...) -- 217.42.77.246 12:02, 4 September 2007 (UTC)
- This page is mostly kept for historical purposes since 'qif' has been deprecated and replaced by m:ParserFunctions. Thus, a move to some other name would not make sense as people would only be looking at it based on it's past history of use under this name. Also, the conditional logic introduced by qif could be used for all kinds of conditions... not just conditional display of rows. As to the name itself, I believe it was short-hand for 'quicker if'... the original 'Template:If' conditional method having been slightly more computationally involved than qif. --CBD 13:07, 4 September 2007 (UTC)
- Can it at least be marked as historical, then, so that people coming across it for the first time don't start wondering what on earth it is? -- 217.42.77.246 17:30, 4 September 2007 (UTC)
- I went to do that... and found that the page has been completely rewritten. It now covers the use of the #if parserFunction for table logic (both columns and rows) rather than Qif at all. Oops, sorry about that. As such I agree that a name change makes sense. How about something like 'Wikipedia:Conditional tables'? --CBD 23:33, 5 September 2007 (UTC)
- Sounds OK to me... -- 86.133.138.146 14:47, 7 September 2007 (UTC)
Please help with Rows in tables
editI'm trying to follow the correct usage plan A and when I include <tr> and <td> commands in my templates (to construct tables, rows and cells) the output I receive is <tr> and <td> rather than it interpreting as HTML tags. What am I doing wrong? Please help. 118.209.133.131 (talk) 04:07, 4 August 2012 (UTC)
- OK I think I have worked it out. If I use wiki text to create the table and HTML tags to create cells it doesn't work. But if I go 100% HTML tags then it works. This is what I'm doing now and getting all my work done a lot quicker now. Previously I had problems where extra paragraphs would appear and if I pushed the wiki text on the same line then it would do different things. Wiki text appears somewhat useless for tables. 118.209.133.131 (talk) 06:52, 4 August 2012 (UTC)
- You don't actually say which page this is on, and your contributions don't list any edits to pages other than this one. If you give the article name, we may be able to fix up any tables in that article. --Redrose64 (talk) 16:28, 4 August 2012 (UTC)
Using ifdef in a template
editHello, I'm stuck in front of a problem I can't understand. I try to change the background of a table cell conditionnally with ifdef using styles. That is to say, in my template which looks like {{mymodel|Value|value2|value3}}, if my Value isn't defined {{mymodel||bla|bla}}, I want the background to be grey.
To do so, I implemented this code :
| align="center" {{ifdef|{{{1}}}|style="background:#999999"|alt=}} | {{{1}}}
The code of my template ifdef seems actually weird, The source code is as follows :
{{var1|1={{{2}}}|1{{{1}}}={{{alt}}}}}
Obviously, my code doesn't run, it prints what I want in the celle but doesn't format it.
Does anyone have an idea how to achieve what I want ? Or some clues? Thank you very much! Moutonjr (talk) 09:46, 30 April 2013 (UTC)
- There is no template named
{{mymodel}}
, nor one named{{ifdef}}
. In the case of ifdef, are you perhaps thinking of one of the parser functions? --Redrose64 (talk) 10:02, 30 April 2013 (UTC)- Actually, I named my own model like this for the example :). I try to use the Parser Function #if but now I've got another problem... I tried to type :
| align="center" {{#if: {{{1|}}} |style="background:#999999" |}} | {{{1}}}
- but now with or without the model [Template:M used with invalid code '!'. See documentation.], it shows "style="background:#999999" |}} | {{{1}}}" in my cell. Do you have an idea how to fix it ? --Moutonjr (talk) 12:13, 30 April 2013 (UTC)
- Which page is this on? I would like to examine it directly, but I don't see anything relevant in either Special:Contributions/Moutonjr or fr:Spécial:Contributions/Moutonjr. --Redrose64 (talk) 12:57, 30 April 2013 (UTC)
the problem of hiding rows in tables with background color
editI use #if in a template to hide rows on some conditions. all works fine except the background color. I'd like to post the template's sample codes below:
{|style="background-color:red;" !<center>会议</center> !<center>时间</center> !<center>地点</center> !<center>重要讲话</center> !<center>关键词</center> |- |{{#if:{{{2014t|}}}|<center>2014年</center> {{!}}{{{2014t}}} {{!}}{{{2014p}}} {{!}}[[{{{2014s}}}]] {{!}}{{#if:{{{2014k|}}}|{{{2014k}}}|}} |}} |- |{{#if:{{{2013t|}}}|<center>2013年</center> {{!}}{{{2013t}}} {{!}}{{{2013p}}} {{!}}[[{{{2013s}}}]] {{!}}{{#if:{{{2013k|}}}|{{{2013k}}}|}} |}} |- |{{#if:{{{2012t|}}}|<center>2012年</center> {{!}}{{{2012t}}} {{!}}{{{2012p}}} {{!}}[[{{{2012s}}}]] {{!}}{{#if:{{{2012k|}}}|{{{2012k}}}|}} |}} |- |{{#if:{{{2011t|}}}|<center>2011年</center> {{!}}{{{2011t}}} {{!}}{{{2011p}}} {{!}}[[{{{2011s}}}]] {{!}}{{#if:{{{2011k|}}}|{{{2011k}}}|}} |}} |}
the background color seems strange at the top and the bottom of the table. anyone can help? thanks. Ywanght (talk) 14:49, 4 March 2014 (UTC)
Looking up a cell within a table
editThis help request has been answered. If you need more help, you can , contact the responding user(s) directly on their user talk page, or consider visiting the Teahouse. |
Is there a way of writing a code to search a table for a value, and then use an if statement on it. For example:
p | q |
r | s |
If I wanted to look up if cell A1 contained 'p', could I do it?--Launchballer 16:40, 15 March 2018 (UTC)
- Launchballer, what are you planning on doing if a cell contained "p"? Because if you were just curious if it contained a "p", then you would use an
#ifeq:
call. Primefac (talk) 22:06, 15 March 2018 (UTC)- Primefac Do you know anything about Countdown? I want to count back 64 episodes from the most recently broadcast episode. It's for the seed table at [1], I want to subtract the most recently broadcast episode from the first quarter final. With less than 64 episodes to be broadcast, the person at the top of the leaderboard is guaranteed a spot there.--Launchballer 22:16, 15 March 2018 (UTC)
- Could you give an example, like, what you want it to look like before and after the "65th" entry is added? Doesn't have to be a full table, just gives me some sort of indication what you're specifically looking for. Primefac (talk) 22:20, 15 March 2018 (UTC)
- Now I think about it, I don't think you need to read values from elsewhere in a table. I'm muddling up parameters and rows.
- Could you give an example, like, what you want it to look like before and after the "65th" entry is added? Doesn't have to be a full table, just gives me some sort of indication what you're specifically looking for. Primefac (talk) 22:20, 15 March 2018 (UTC)
- Primefac Do you know anything about Countdown? I want to count back 64 episodes from the most recently broadcast episode. It's for the seed table at [1], I want to subtract the most recently broadcast episode from the first quarter final. With less than 64 episodes to be broadcast, the person at the top of the leaderboard is guaranteed a spot there.--Launchballer 22:16, 15 March 2018 (UTC)
p | {{#if:{{#expr:<first quarterfinal/> - <most recently broadcast episode/>}} < 64|'''seed 1'''|seed 1}} |
- I think I can do that on my own.--Launchballer 22:34, 15 March 2018 (UTC)
- Primefac Ah! How do you go about finding the first cell to contain exactly " - "?--Launchballer 22:38, 15 March 2018 (UTC)
- An
#ifeq:<param>|-|
call. Primefac (talk) 22:55, 15 March 2018 (UTC)
- An
Conditional number of lines/raw?
editHow to make a table with a conditional number of lines or raws?
For instance, if the variable number_of_lines is 3, it generates 3 lines? — Preceding unsigned comment added by 87.91.51.235 (talk) 12:15, 17 November 2019 (UTC)
- You would need to use a template to do this; the default "table-creation" setup wouldn't work like that. Primefac (talk) 13:09, 17 November 2019 (UTC)