Content deleted Content added
CBDunkerson (talk | contribs) →Requested move: Do not move |
→Conditional columns: Mentioned in the intro, then not again afterward. |
||
(48 intermediate revisions by 22 users not shown) | |||
Line 1:
{{WikiProject banner shell|
{{Wikipedia Help Project|class=start|importance=Low}}
}}
== MUST use HTML ==
Line 26 ⟶ 27:
: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. —[[User:Locke Cole|Locke Cole]] • [[User talk:Locke Cole|t]] • [[Special:Contributions/Locke Cole|c]] 16:14, 17 March 2006 (UTC)
:: I tried to understand {{Lts|boolexists}} because I don't like {{Tl|Qif}} and want a simpler <
*: The point ''MUST use HTML'' turned out to be wrong, see below and {{Lts|!}}, it's more like ''MAY use XHTML''. [[User:Omniplex|Omniplex]] 11:20, 21 March 2006 (UTC)
Line 32 ⟶ 33:
== New attempt ==
:''Note: most of the templates referred to in this discussion have since been repurposed for other tasks.'' [[User:Happy-melon|<b style="color: forestgreen;[[Media:Example.ogg]]">Happy</b>]]‑[[User talk:Happy-melon|<b style="color: darkorange;">melon</b>]] 13:17, 26 September 2008 (UTC)
Mixing XHTML with Wiki table syntax is a layer violation, and some uses in {{Lcs|Wikipedia header templates}} for the shortcut are incorrect, <s>missing <tr> and similar issues, in other words FUBAR</s>.
But it should be possible to get it to work somehow with Wiki syntax.
Line 50 ⟶ 53:
Apparently that works, we need a <s>'''shorter''' name for
the</s> template returning a vertical bar... ;-) [[User:Omniplex|Omniplex]] 13:57, 19 March 2006 (UTC)
:Hm, we could always use {{tl|
<pre>{| class="infobox"
{{qif|test={{{foo|}}}|then=
{{
! Foo
{{TD}} {{{foo}}}
Line 68 ⟶ 71:
::: Well, if you just want to make a template for the vertical bar, I note that {{tl|B}} and {{tl|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 {{tl|qif}} can be neatly separated.
::::2008 update: {{tl|B}} is no longer available. — <b><span style="font-family:Tahoma;">[[User:SMcCandlish|SMcCandlish]]</span></b> [[[User talk:SMcCandlish|talk]]] [[[Special:Contributions/SMcCandlish|cont]]] <b>‹(-¿-)›</b> 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. =) —[[User:Locke Cole|Locke Cole]] • [[User talk:Locke Cole|t]] • [[Special:Contributions/Locke Cole|c]] 22:10, 19 March 2006 (UTC)
Line 77 ⟶ 80:
:::::As straight forward as possible. [[User:Omniplex|Omniplex]] 22:31, 20 March 2006 (UTC)
::::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 {{Tl|Qif}}, only the vertical bar has to be escaped from the [[m:Help:Parameter default|parameter default]] mechanism. Normally <
== [[Template:Ifdef|Ifdef]] ==
Line 101 ⟶ 104:
|-
| valign="top" | {{tlx|qif_example_2/b}}
| valign="top" | <pre>{{qif_example_2/b}}</pre>
|-
| valign="top" | {{tlx|qif_example_2/b|foo=}}
| valign="top" | <pre>{{qif_example_2/b|foo=}}</pre>
|-
| valign="top" | {{tlx|qif_example_2/b|foo=|bar=vbar}}
| valign="top" | <pre>{{qif_example_2/b|foo=|bar=vbar}}</pre>
|-
| valign="top" | {{tlx|qif_example_2/b|foo=value}}
| valign="top" | <pre>{{qif_example_2/b|foo=value}}</pre>
|-
| valign="top" | {{tlx|qif_example_2/b|foo=value|bar=vbar}}
| valign="top" | <pre>{{qif_example_2/b|foo=value|bar=vbar}}</pre>
|}
Line 128 ⟶ 131:
it's so fragile. -- [[User:Omniplex|Omniplex]] 16:17, 27 March 2006 (UTC)
Answered by [[User:Paddu|Paddu]] in [[Template talk:Ifdef|Ifdef]], executive summary: Use {{Tlx|ifdef|test|2=then}} if '''then''' contains any "<
=== TfD nomination of Template:Ifdef ===
Line 160 ⟶ 163:
|-
| valign="top" | {{tlx|qif_example_2b}}
| valign="top" | <pre>{{qif_example_2b}}</pre>
|-
| valign="top" | {{tlx|qif_example_2b|foo=}}
| valign="top" | <pre>{{qif_example_2b|foo=}}</pre>
|-
| valign="top" | {{tlx|qif_example_2b|foo=|bar=vbar}}
| valign="top" | <pre>{{qif_example_2b|foo=|bar=vbar}}</pre>
|-
| valign="top" | {{tlx|qif_example_2b|foo=value}}
| valign="top" | <pre>{{qif_example_2b|foo=value}}</pre>
|-
| valign="top" | {{tlx|qif_example_2b|foo=value|bar=vbar}}
| valign="top" | <pre>{{qif_example_2b|foo=value|bar=vbar}}</pre>
|}
Line 236 ⟶ 239:
I've updated the instructions to use <code>#if</code> instead of {{tl|qif}}. The only loose-end that remains is updating {{tl|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 <code>#ifeq</code>, <code>#ifexpr</code> 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. =) —[[User:Locke Cole|Locke Cole]] • [[User talk:Locke Cole|t]] • [[Special:Contributions/Locke Cole|c]] 05:47, 17 April 2006 (UTC)
:I've added a caveat about "'''<
::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. —[[User:Locke Cole|Locke Cole]] • [[User talk:Locke Cole|t]] • [[Special:Contributions/Locke Cole|c]] 16:27, 18 April 2006 (UTC)
:::Double redirects are shown, but what about dozens of <small><
::::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. —[[User:Locke Cole|Locke Cole]] • [[User talk:Locke Cole|t]] • [[Special:Contributions/Locke Cole|c]] 01:00, 22 April 2006 (UTC)
Line 257 ⟶ 260:
| <small><pre>{{#if: {{{tst}}} | -1- {{{1}}} }}</pre></small>
| {{#if: {{{tst}}} | -1- {{{1}}} }}
| <pre>{{ifdef | {{{tst}}} | -1- {{{1}}} }}</pre>
|-
| <small><pre>{{#if: {{{tst}}} | -2- {{{1|default}}} }}</pre></small>
| {{#if: {{{tst}}} | -2- {{{1|default}}} }}
| <pre>{{ifdef | {{{tst}}} | -2- {{{1|default}}} }}</pre>
|-
| <small><pre>{{#if: {{{tst}}} | -3- {{{2}}} | '''err''' }}</pre></small>
| {{#if: {{{tst}}} | -3- {{{2}}} | '''err''' }}
| <pre>{{ifdef | {{{tst}}} | -3- {{{2}}} | *** }}</pre>
|-
| <small><pre>{{#if: {{{tst}}} | -4- {{{2}}} }}</pre></small>
| {{#if: {{{tst}}} | -4- {{{2}}} }}
| <pre>{{ifdef | {{{tst}}} | -4- {{{2}}} }}</pre>
|}{{-}}
Line 279 ⟶ 282:
| <small><pre>{{#if: {{ns:0}} |n/a| -1- {{{2}}} }}</pre></small>
| {{#if: {{ns:0}} |n/a| -1- {{{2}}} }}
| <pre>{{ifndef |{{ns:0}}| -1- {{{2}}} }}</pre>
|-
| <small><pre>{{#if: {{ns:0}} |n/a| -2- {{{2|default}}} }}</pre></small>
| {{#if: {{ns:0}} |n/a| -2- {{{2|default}}} }}
| <pre>{{ifndef |{{ns:0}}| -2- {{{2|default}}} }}</pre>
|-
| <small><pre>{{#if: {{ns:0}} |n/a| -3- {{{1}}} }}</pre></small>
| {{#if: {{ns:0}} |n/a| -3- {{{1}}} }}
| <pre>{{ifndef |{{ns:0}}| -3- {{{1}}} }}</pre>
|-
| <small><pre>{{#if: {{ns:0}} |n/a| -4- {{{3}}} }}</pre></small>
| {{#if: {{ns:0}} |n/a| -4- {{{3}}} }}
| <pre>{{ifndef |{{ns:0}}| -4- {{{3}}} }}</pre>
|}
Line 307 ⟶ 310:
| style="border:1px solid #a3bfb1; background:#f5fffa;"|{{{Date of Retirement}}} | }}</pre>
The above shows:<pre>
{{#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}}} | }}</pre>
But that has the "|" for wiki tables, so I make them into the <pre><td><tr><th></pre> ones.
Line 320 ⟶ 323:
That shows this:
{{#if: {{{Date of Retirement|}}}|{{{
<table><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></table> | }}
Could anyone help me with this?
Line 339 ⟶ 342:
{{!}} style="border:1px solid #a3bfb1; background:#f5fffa;"{{!}}{{{Date of Retirement|Date}}}
{{!}}}| }}
<!-- Template:Unsigned --><span class="autosigned" style="font-size:85%;">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:CBDunkerson|CBDunkerson]] ([[User talk:CBDunkerson#top|talk]] • [[Special:Contributions/CBDunkerson|contribs]]) 6:52, 3 September 2006 (UTC)</span>
== Logical and/or question ==
Line 345 ⟶ 349:
:Nevermind, I figured it out. For or at least you just do {{#if:<nowiki>{{{param1|}}}{{{param2|}}}</nowiki>|then case... — [[User:George.Saliba|George Saliba]]<sup> <nowiki>[</nowiki>[[User talk:George.Saliba|talk]]<nowiki>]</nowiki></sup> 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. [[User:Hypertall|Hypertall]] ([[User talk:Hypertall|talk]]) 21:59, 6 May 2012 (UTC)
:::It's more complicated, but possible:
:::<code><nowiki>{{#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}}</nowiki></code>
:::--[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] ([[User talk:Redrose64|talk]]) 23:05, 6 May 2012 (UTC)
== Help with conditionals with specific variables and if/then ==
Line 355 ⟶ 364:
: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. --[[User talk:CBDunkerson|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? -- [[User:217.42.77.246|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'? --[[User talk:CBDunkerson|CBD]] 23:33, 5 September 2007 (UTC)
:::: Sounds OK to me... -- [[User:86.133.138.146|86.133.138.146]] 14:47, 7 September 2007 (UTC)
== Please help with Rows in tables ==
<nowiki>I'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.</nowiki> [[Special:Contributions/118.209.133.131|118.209.133.131]] ([[User talk: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. [[Special:Contributions/118.209.133.131|118.209.133.131]] ([[User talk:118.209.133.131|talk]]) 06:52, 4 August 2012 (UTC)
::You don't actually say which page this is on, and [[Special:Contributions/118.209.133.131|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. --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] ([[User talk:Redrose64|talk]]) 16:28, 4 August 2012 (UTC)
== Using ifdef in a template ==
Hello,
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 <nowiki>{{mymodel|Value|value2|value3}}</nowiki>, if my Value isn't defined <nowiki>{{mymodel||bla|bla}}</nowiki>, I want the background to be grey.
To do so, I implemented this code :
<pre> | align="center" {{ifdef|{{{1}}}|style="background:#999999"|alt=}} | {{{1}}} </pre>
The code of my template ifdef seems actually weird, The source code is as follows :
<pre>{{var1|1={{{2}}}|1{{{1}}}={{{alt}}}}}</pre>
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! [[User:Moutonjr|Moutonjr]] ([[User talk:Moutonjr|talk]]) 09:46, 30 April 2013 (UTC)
:There is no template named {{tlx|mymodel}}, nor one named {{tlx|ifdef}}. In the case of ifdef, are you perhaps thinking of one of the [[WP:PF|parser functions]]? --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] ([[User talk: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 :
::<pre> | align="center" {{#if: {{{1|}}} |style="background:#999999" |}} | {{{1}}}</pre>
::but now with or without the model {{m|!}}, it shows "<nowiki>style="background:#999999" |}} | {{{1}}}</nowiki>" in my cell. Do you have an idea how to fix it ? --[[User:Moutonjr|Moutonjr]] ([[User talk: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]]. --[[User:Redrose64|<span style="color:#a80000; background:#ffeeee; text-decoration:inherit">Red</span>rose64]] ([[User talk:Redrose64|talk]]) 12:57, 30 April 2013 (UTC)
:::: It is in a local Wikimedia, but my version seems outdated according to [[pl:Wikipedysta:Matma_Rex|MatmaRex]] on IRC, my version is outdated because it works for Wikipedia (1.22) but not in my 1.16. Sorry for the inconvenience... <!-- Template:Unsigned --><span class="autosigned" style="font-size:85%;">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:Moutonjr|Moutonjr]] ([[User talk:Moutonjr#top|talk]] • [[Special:Contributions/Moutonjr|contribs]]) 13:23, 30 April 2013 (UTC)</span>
==the problem of hiding rows in tables with background color==
I 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:
<pre>
{|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}}}|}}
|}}
|}
</pre>
the background color seems strange at the top and the bottom of the table. anyone can help? thanks.
[[User:Ywanght|Ywanght]] ([[User talk:Ywanght|talk]]) 14:49, 4 March 2014 (UTC)
== Looking up a cell within a table ==
{{help me-helped}}
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:
{| class="wikitable" name="table"
| p
| q
|-
| r
| s
|}
If I wanted to look up if cell A1 contained 'p', could I do it?--<span style="background:#FF0;font-family:Rockwell Extra Bold">[[User:Launchballer|<u style="color:#00F">Laun</u>]][[User talk:Launchballer|<u style="color:#00F">chba</u>]][[Special:Contribs/Launchballer|<u style="color:#00F">ller</u>]]</span> 16:40, 15 March 2018 (UTC)
:{{u|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 <code>#ifeq:</code> call. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 22:06, 15 March 2018 (UTC)
::{{u|Primefac}} Do you know anything about [[Countdown (game show)|Countdown]]? I want to count back 64 episodes from the most recently broadcast episode. It's for the seed table at [http://wiki.apterous.org/Series_78], 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.--<span style="background:#FF0;font-family:Rockwell Extra Bold">[[User:Launchballer|<u style="color:#00F">Laun</u>]][[User talk:Launchballer|<u style="color:#00F">chba</u>]][[Special:Contribs/Launchballer|<u style="color:#00F">ller</u>]]</span> 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. [[User:Primefac|Primefac]] ([[User talk: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.
{| class="wikitable" name="table"
| p
| <nowiki>{{#if:{{#expr:<first quarterfinal/> - <most recently broadcast episode/>}} < 64|'''seed 1'''|seed 1}}</nowiki>
|}
::::I think I can do that on my own.--<span style="background:#FF0;font-family:Rockwell Extra Bold">[[User:Launchballer|<u style="color:#00F">Laun</u>]][[User talk:Launchballer|<u style="color:#00F">chba</u>]][[Special:Contribs/Launchballer|<u style="color:#00F">ller</u>]]</span> 22:34, 15 March 2018 (UTC)
::::{{u|Primefac}} Ah! How do you go about finding the first cell to contain exactly " - "?--<span style="background:#FF0;font-family:Rockwell Extra Bold">[[User:Launchballer|<u style="color:#00F">Laun</u>]][[User talk:Launchballer|<u style="color:#00F">chba</u>]][[Special:Contribs/Launchballer|<u style="color:#00F">ller</u>]]</span> 22:38, 15 March 2018 (UTC)
:::::An <code>#ifeq:<param>|-|</code> call. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 22:55, 15 March 2018 (UTC)
== Conditional number of lines/raw? ==
How 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? <!-- Template:Unsigned IP --><small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/87.91.51.235|87.91.51.235]] ([[User talk:87.91.51.235#top|talk]]) 12:15, 17 November 2019 (UTC)</small> <!--Autosigned by SineBot-->
:You would need to use a template to do this; the default "table-creation" setup wouldn't work like that. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 13:09, 17 November 2019 (UTC)
== Conditional columns ==
The intro sentence mentions conditional columns, but then they are never mentioned again. I have a table with conditional columns, but I don't know if there's any demand for this elsewhere. If there's interest, ping me and I'll look into seeing whether it's worth generalizing a one-off into something more usable, or just documenting what I have. [[User:Mathglot|Mathglot]] ([[User talk:Mathglot|talk]]) 11:26, 5 February 2025 (UTC)
|