Help talk:Conditional tables

message: Not really necessary to invent a third method, but I'm
interested to get some ideas about its fragility:

Bar	

The code above is in . The table 
below demonstrates the effect when it's used:
Template call	Result
             	
             	
             	
             	
             	
So far apparently fine, but it didn't work with
at least one of the Wikipedia header templates.
The  code is straight from Meta. It's the
 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)
replies: text: 
Foo	
Bar	

The code above is in . The table 
below demonstrates the effect when it's used:
Template call	Result
             	
             	
             	
             	
             	
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)

text: 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)
thread_title:  [[Template:Ifdef|Ifdef]] 

message: Template: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)
thread_title:  TfD nomination of Template:Ifdef 

message: After 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
:  

Foo	
Bar	

The code above is in . The table 
below demonstrates the effect when it's used:
Template call	Result
             	
             	
             	
             	
             	
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)
replies: text: 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)
thread_title:  Direct ifdef approach 

message: :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)
replies: text: Done. --CBDunkerson 20:36, 8 April 2006 (UTC)

text: My bad, I didn't expect a protection when I redirected it. -- Omniplex 20:50, 8 April 2006 (UTC)
thread_title:  Interwiki link to vi: 

message: 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

This does not;
|- valign=top 
Essentially, #if: ignores the line break after the condition and the second scenario above resolves as;
|- valign=top | Parameter:
| <value of >
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. , , ) 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)
replies: text: 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)

text: Stuff written by me now documented in mediazilla:5569 removed here, the <pre> bugs are unrelated to  and #if; oddities. -- Omniplex 22:23, 17 April 2006 (UTC)
thread_title:  [[m:ParserFunctions]] 

message: I've updated the instructions to use #if instead of . The only loose-end that remains is updating  (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)
replies: text: I've added a caveat about "=" and positional parameters. Where  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)
replies: text: 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)
replies: text: 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)
replies: text: 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)
thread_title:  Updated instructions 

message: A 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 ===
Code                                     	Result	ifdef
        	      	
	      	
  	      	
        	      	
=== #if: else  anomaly ===
Code                                        	Result	ifndef
        	      	
	      	
        	      	
        	      	
-- Omniplex 00:28, 28 April 2006 (UTC)
replies: text: You might want to look at http://test.wikipedia.org/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)
replies: text: 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)
thread_title:  #if: 5678 watch 

message: Code                                        	Result	ifndef
        	      	
	      	
        	      	
        	      	
-- Omniplex 00:28, 28 April 2006 (UTC)
replies: text: You might want to look at http://test.wikipedia.org/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)
replies: text: 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)
thread_title:  #if: else {&#123;{2}&#125;} anomaly 

message: I'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: |{
The above shows:
{{#if: |{
But that has the "|" for wiki tables, so I make them into the  ones.
{{#if: |{{{
 Date of Set Retirement :
 | }}
That shows this:
{{#if: |{
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;

Shows:
— Preceding unsigned comment added by CBDunkerson (talk • contribs) 6:52, 3 September 2006 (UTC)
thread_title:  Use with table formating

message: I 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)
thread_title:  Help with conditionals with specific variables and if/then 

message: Wikipedia: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)
replies: text: 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)
replies: text:  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)
replies: text: 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)
replies: text:  Sounds OK to me... -- 86.133.138.146 14:47, 7 September 2007 (UTC)
thread_title:  Requested move 

message: I'm trying to follow the correct usage plan A and when I include  and  commands in my templates (to construct tables, rows and cells) the output I receive is  and  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)
replies: text: 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)
replies: text: 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)
thread_title:  Please help with Rows in tables 

message: 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:

会议  	时间  	地点  	重要讲话    	关键词
    	    	    	        	
    	    	    	        	
    	    	    	        	
    	    	    	        	

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)
thread_title: the problem of hiding rows in tables with background color

message: 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?  — Preceding unsigned comment added by 87.91.51.235 (talk) 12:15, 17 November 2019 (UTC)
replies: text: 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)
thread_title:  Conditional number of lines/raw?