Generating tabular output (examples): Difference between revisions

From DynamicPageList3 Manual
Content added Content deleted
fts>Gero
(New page: {{Type:Test |parameter = table }} 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 na...)
 
fts>Eep²
m (link)
Line 3: Line 3:
}}
}}


The following tests explain how to use the <tt>table</tt> command.
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.
We have a set of documents (starting with ''Some Article ..'') and a test template named ''Some Template'' and ''Some Template.dpl'', respectively.


== A: just get one column from a template invocation ==
== A: just get one column from a template invocation ==

Revision as of 08:31, 7 September 2007

Template:Type:Test

The following tests explain how to use the table command. We have a set of documents (starting with Some Article ..) and a test template named Some Template and Some Template.dpl, respectively.

A: just get one column from a template invocation

 |include    = {Some Template}:parm1
 |table      = ,,The first parameter of the Template Call

{{#dpl:

 |titlematch = Some Article %
 |include    = {Some Template}:parm1
 |table      = ,,The first parameter of the Template Call

}}

A2: just get one column from a template invocation

 |include    = {Some Template}:parm1
 |table      = ,-,The first parameter of the Template Call

{{#dpl:

 |titlematch = Some Article %
 |include    = {Some Template}:parm1
 |table      = ,-,The first parameter of the Template Call

}} 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

 |include=#Chapter X
 |table=,,X

{{#dpl:

 |titlematch=Some Article %
 |include=#Chapter X
 |table=,,X

}}


B2: one chapter, one line per article

 |include=#dummy,#Chapter X
 |table=,,,X

{{#dpl:

 |titlematch=Some Article %
 |include=#dummy,#Chapter X
 |table=,,,X

}} 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

{{#dpl:

 |titlematch=Some Article %
 |include=#Chapter X,#Chapter Z
 |table=,,X,Z

}}

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

{{#dpl:

 |titlematch=Some Article %
 |include=#dummy, #Chapter X, #Chapter Z
 |table=,,,X,Z

}}

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

{{#dpl:

 |titlematch=Some Article %
 |include = {Some Template}.dpl
 |table   = ,,T1 - p1, T1 - p2

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

D2: invoke a phantom template

 |include = #dummy,{Some Template}.dpl2
 |table   = ,,,Template invocations

{{#dpl:

 |titlematch=Some Article %
 |include = #dummy,{Some Template}.dpl2
 |table   = ,,,Template invocations

}} 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

 |include={Some Template}.dpl,#Chapter X,#Chapter Z
 |table=,,tpl:parm1,tpl:parm2,Chapter X,Chapter Z

{{#dpl:

 |titlematch=Some Article %
 |include={Some Template}.dpl,#Chapter X,#Chapter Z
 |table=,,tpl:parm1,tpl:parm2,Chapter X,Chapter Z

}}

E2: A combination of all

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

{{#dpl:

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

}}

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