Difference between revisions of "Test table"

From FollowTheScore
Jump to: navigation, search
m (intro - add Template:tl to make it easier to navigate example pages)
 
(One intermediate revision by one other user not shown)
Line 3: Line 3:
 
}}
 
}}
  
The following tests explain how to use the <tt>[[table]]</tt> command. We have a set of documents (starting with ''Some Article ..'') and a test template named ''Some Template'' and ''Some Template.dpl'', respectively.
+
The following tests explain how to use the <tt>[[table]]</tt> command. We have a set of documents ([[Some Article 1]] thru [[Some Article 6]]) and test templates named {{tl|Some Template}} and {{tl|Some Template.dpl}} used in the examples below.
  
 
Please note that there is another '''example''' for creative use of the <tt>table</tt> command in the '''[[Talk:Test table|discussion page]]'''.
 
Please note that there is another '''example''' for creative use of the <tt>table</tt> command in the '''[[Talk:Test table|discussion page]]'''.
Line 58: Line 58:
  
 
== B: just get one chapter ==
 
== B: just get one chapter ==
 +
In this example we also demonstrate sorting;
 +
negative numbers result in descending sort order.
  
 
   |include  = #Chapter X
 
   |include  = #Chapter X
 
   |table    = ,,X
 
   |table    = ,,X
 
   |tablerow = bgcolor=#ffeeee¦%%
 
   |tablerow = bgcolor=#ffeeee¦%%
 +
  |tablesortcol = -1
 
{{#dpl:
 
{{#dpl:
 
   |titlematch=Some Article %
 
   |titlematch=Some Article %
Line 67: Line 70:
 
   |table    = ,,X
 
   |table    = ,,X
 
   |tablerow = bgcolor=#ffeeee¦%%
 
   |tablerow = bgcolor=#ffeeee¦%%
 +
  |tablesortcol = -1
 
}}
 
}}
 
  
 
== B2: one chapter, one line per article ==
 
== B2: one chapter, one line per article ==

Latest revision as of 02:37, 17 July 2008

Test table

The following tests explain how to use the table command. We have a set of documents (Some Article 1 thru Some Article 6) and test templates named {{Some Template}} and {{Some Template.dpl}} used in the examples below.

Please note that there is another example for creative use of the table command in the discussion page.

A1: just get one column from a template invocation

 |include    = {Some Template}:parm1
 |table      = ,,The first parameter
of the Template Call |tablerow = bgcolor=#eeffee¦%%
Content page The first parameter
of the Template Call
Some Article 6
Some Article 4
Some Article 5 some value 5-1-1
Some Article 3 some value 3-1-1
Some Article 3 some value 3-2-1
Some Article 2
Some Article 1 some value 1-1-1
Some Article 1 some value 1-2-1
Some Article 1 some value 1-3-1

A2: putting the link into the second column

 |include    = {Some Template}:parm1:%PAGE%
 |table      = ,-,The first parameter
of the Template Call,Link to the article |tablerow = bgcolor=#eeffee¦%%,%%
The first parameter
of the Template Call
Link to the article
some value 5-1-1 Some Article 5
some value 3-1-1 Some Article 3
some value 3-2-1 Some Article 3
some value 1-1-1 Some Article 1
some value 1-2-1 Some Article 1
some value 1-3-1 Some Article 1

A3: just get one column from a template invocation (sortable table)

 |include    = {Some Template}:parm1
 |table      = class=sortable,,The first parameter
of the Template Call |tablerow = bgcolor=#eeffee¦%%
Content page The first parameter
of the Template Call
Some Article 6
Some Article 4
Some Article 5 some value 5-1-1
Some Article 3 some value 3-1-1
Some Article 3 some value 3-2-1
Some Article 2
Some Article 1 some value 1-1-1
Some Article 1 some value 1-2-1
Some Article 1 some value 1-3-1

A4: just get one column from a template invocation

 |include    = {Some Template}:parm1
 |table      = ,-,The first parameter of the Template Call
 |tablerow   = bgcolor=#eeffee¦%%
The first parameter
of the Template Call
some value 5-1-1
some value 3-1-1
some value 3-2-1
some value 1-1-1
some value 1-2-1
some value 1-3-1

A single '-' instead of a column name for the hyperlink to the article will suppress that column. Note that in this configuration articles are completely missing if they do not contain a Call of Template:Some Template.

B: just get one chapter

In this example we also demonstrate sorting; negative numbers result in descending sort order.

 |include  = #Chapter X
 |table    = ,,X
 |tablerow = bgcolor=#ffeeee¦%%
 |tablesortcol = -1
Content page X
Some Article 6
Some Article 5
Some Article 4
Some Article 3
Some Article 2

chapter X of article 2, occurence 1

Some Article 2

chapter X of article 2, occurence 2

Some Article 2

chapter X of article 2, occurence 3

Some Article 1

chapter X of article 1, occurence 1

Some Article 1

chapter X of article 1, occurence 2

B2: one chapter, one line per article

 |include  = #dummy,#Chapter X
 |table    = ,,,X
 |tablerow = ,bgcolor=#ffeeee¦%%
Content page X
Some Article 6
Some Article 4
Some Article 5
Some Article 3
Some Article 2

chapter X of article 2, occurence 1


chapter X of article 2, occurence 2


chapter X of article 2, occurence 3

Some Article 1

chapter X of article 1, occurence 1


chapter X of article 1, occurence 2

Using a dummy parameter (and adding an empty column header -- set the three commas at 'table=,,,X') leads to only ONE line per article. Not very clean, but it works.

C: get two different chapters

  |include = #Chapter X,#Chapter Z
  |table   = ,,X,Z
  |tablerow = bgcolor=#ffeeee¦%%,bgcolor=#ffffee¦<i><small>%%</small></i>
Content page X Z
Some Article 6
Some Article 4

chapter Z of article 4

Some Article 5
Some Article 3
Some Article 2

chapter X of article 2, occurence 1

Some Article 2

chapter X of article 2, occurence 2

Some Article 2

chapter X of article 2, occurence 3

Some Article 1

chapter X of article 1, occurence 1

Some Article 1

chapter X of article 1, occurence 2

Chapter Z (1) of article 1


Chapter Z (2) of article 1

Note that a new table row is started for every occurence of Chapter X (being the first chapter mentioned in the include statement). The contents of all other columns (in this case Chapter Z) is only shown in the LAST row of each article. If there are multiple occurencies of Chapter Z, they will be separated by a horizontal line (or ony by a line break if you put a space before the "#Chapter Z" in the iclude statement).

C2: get two different chapters

 |include=#dummy, #Chapter X, #Chapter Z
 |table=,,,X,Z
Content page X Z
Some Article 6
Some Article 4

chapter Z of article 4

Some Article 5
Some Article 3
Some Article 2

chapter X of article 2, occurence 1

chapter X of article 2, occurence 2

chapter X of article 2, occurence 3

Some Article 1

chapter X of article 1, occurence 1

chapter X of article 1, occurence 2

Chapter Z (1) of article 1

Chapter Z (2) of article 1

Again we used the trick with the dummy parameter at include. As we put a space before the '#Chapter X' we do not even get horizontal separators betrween the chapter texts.

D: invoke a phantom template

 |include = {Some Template}.dpl
 |table   = ,,T1 - p1, T1 - p2
Content page T1 - p1 T1 - p2
Some Article 6
Some Article 4
Some Article 5 some value 5-1-1

some value 5-1-2

Some Article 3 some value 3-1-1

some value 3-1-2

Some Article 3 some value 3-2-1

some value 3-2-2

Some Article 2
Some Article 1 some value 1-1-1

some value 1-1-2

Some Article 1 some value 1-2-1

some value 1-2-2

Some Article 1 some value 1-3-1

some value 1-3-2

We need two column headers as Template:Some Template.dpl produces two columns of output


D1: use template parameters without phantom template

 |include = {Some Template}:parm1:parm2[12]
 |table   = ,,T1 - p1, T1 - p2

We delimit the contents of parm2 to 12 characters; note that word boundaries are used to cut the text; so we only get the first two words (=10 characters)

Content page T1 - p1 T1 - p2
Some Article 6
Some Article 4
Some Article 5 some value 5-1-1 some value
Some Article 3 some value 3-1-1 some value
Some Article 3 some value 3-2-1 some value
Some Article 2
Some Article 1 some value 1-1-1 some value
Some Article 1 some value 1-2-1 some value
Some Article 1 some value 1-3-1 some value

D2: invoke a phantom template

 |include = #dummy,{Some Template}.dpl2
 |table   = ,,,Template invocations
Content page Template invocations
Some Article 6
Some Article 4
Some Article 5
some value 5-1-1 some value 5-1-2
Some Article 3
some value 3-1-1 some value 3-1-2

some value 3-2-1 some value 3-2-2
Some Article 2
Some Article 1
some value 1-1-1 some value 1-1-2

some value 1-2-1 some value 1-2-2

some value 1-3-1 some value 1-3-2

Note: The trick with the dummy column wouldn´t work with Template:Some Template.dpl because that template produces new columns whenever it is called. So we used a different phantom template here /Template:Some template.dpl2) which creates a little table containing the parameters of each invocation.

E: A combination of all

  |addpagecounter = yes
  |include        = {Some Template}:parm1:parm2,#Chapter X,#Chapter Z
  |table          = ,,tpl:parm1,tpl:parm2,Chapter X,Chapter Z,page count
  |tablerow       = '''%% ''',''%% '',bgcolor=#ffdddd{{!}}%%,bgcolor=#ffffdd{{!}}%%
  |format         = ,,\n{{!}}bgcolor=#ddddff{{!}}%COUNT%

|- |Some Article 6 | | |bgcolor=#ffdddd| |bgcolor=#ffffdd| |bgcolor=#ddddff|%COUNT% |- |Some Article 4 | | |bgcolor=#ffdddd| |bgcolor=#ffffdd| chapter Z of article 4 |bgcolor=#ddddff|%COUNT% |- |Some Article 5 |some value 5-1-1 |some value 5-1-2 |bgcolor=#ffdddd| |bgcolor=#ffffdd| |bgcolor=#ddddff|%COUNT% |- |Some Article 3 |some value 3-1-1 |some value 3-1-2 |- |Some Article 3 |some value 3-2-1 |some value 3-2-2 |bgcolor=#ffdddd| |bgcolor=#ffffdd| |bgcolor=#ddddff|%COUNT% |- |Some Article 2 | | |bgcolor=#ffdddd| chapter X of article 2, occurence 1


chapter X of article 2, occurence 2


chapter X of article 2, occurence 3 |bgcolor=#ffffdd| |bgcolor=#ddddff|%COUNT% |- |Some Article 1 |some value 1-1-1 |some value 1-1-2 |- |Some Article 1 |some value 1-2-1 |some value 1-2-2 |- |Some Article 1 |some value 1-3-1 |some value 1-3-2 |bgcolor=#ffdddd| chapter X of article 1, occurence 1


chapter X of article 1, occurence 2

|bgcolor=#ffffdd| Chapter Z (1) of article 1


Chapter Z (2) of article 1 |bgcolor=#ddddff|%COUNT%

E2: A combination of all

 |include=#dummy,{Some Template}.dpl2,#Chapter X,#Chapter Z
 |table=,-,,Template Invocations,Chapter X,Chapter Z
Template Invocations Chapter X Chapter Z

chapter Z of article 4

some value 5-1-1 some value 5-1-2
some value 3-1-1 some value 3-1-2

some value 3-2-1 some value 3-2-2

chapter X of article 2, occurence 1


chapter X of article 2, occurence 2


chapter X of article 2, occurence 3

some value 1-1-1 some value 1-1-2

some value 1-2-1 some value 1-2-2

some value 1-3-1 some value 1-3-2

chapter X of article 1, occurence 1


chapter X of article 1, occurence 2

Chapter Z (1) of article 1


Chapter Z (2) of article 1

Note the '-' as the second parameter for the table arguments.