Generating tabular output (examples): Difference between revisions

From DynamicPageList3 Manual
Content added Content deleted
imported>FrozenPlum
m (16 revisions imported: Importing from https://followthescore.org/dpldemo/index.php?title=Test_table for adaptation and use on this wiki)
imported>FrozenPlum
m (Flesh out a whole bunch of these (not finished yet, but it's a good start))
Line 1: Line 1:
The following tests explain how to use the {{DPL|table}} parameter.
{{Type Test

|parameter = table
== Include 1 template value==

This selects articles in [[:Category:Fruit examples]] whose article names are automatically generated and placed in the first column. It then includes the "Fruit-Infobox" template "grows" parameter value, which appears in the second column, if the article has a value for <code>grows=</code> on its page (otherwise this cell displays empty). The <code>table=</code> statement sets the table styles (if set) before the first comma, and then sets the header columns text. The <code>tablerow=</code> statement corresponds 1:1 with the position of the include statement ("grows" in the second column) so it colors the second column green and then displays the value carried down <code>%%</code>. The results are limited to a count of 5.

'''Example:'''<br>
<pre>
{{#dpl:
|category = Fruit examples
|include = {Fruit-Infobox}:grows
|table = class="wikitable sortable",Page,The first parameter<br>of the Template Call
|tablerow = style="background:#eeffee;"¦%%
|count = 5
}}
}}
</pre>


'''Result:'''<br>
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.
{{#dpl:
|category = Fruit examples
|include = {Fruit-Infobox}:grows
|table = class="wikitable sortable",Page,The first parameter<br>of the Template Call
|tablerow = style="background:#eeffee;"¦%%
|count = 5
}}


==Omit (automatic) first column==
Please note that there is another '''example''' for creative use of the <tt>table</tt> command in the '''[[Talk:Test table|discussion page]]'''.


This selects articles in [[:Category:Fruit examples]], it includes the "grows" parameter value from "Fruit-Infobox" template. The <code>table</code> statement uses <code>,-,</code> in second position to omit the (automatic) page column, the "grows" value appears there instead. Since the <code>tablerow</code> value corresponds 1:1 to the include statement position, the ''first'' column is styled green, followed by the value carried down using <code>%%</code>.
== A1: just get one column from a template invocation ==


'''Example:'''<br>
|include = {Some Template}:parm1
<pre>
|table = ,,The first parameter<br>of the Template Call
|tablerow = bgcolor=#eeffee¦%%
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch = Some Article %
|include = {Some Template}:parm1
|include = {Fruit-Infobox}:grows
|table = ,,The first parameter<br>of the Template Call
|table = class="wikitable sortable",-,The first parameter<br>of the Template Call
|tablerow = bgcolor=#eeffee¦%%
|tablerow = style="background:#eeffee;"¦%%
|count = 5
}}
}}
</pre>


'''Result:'''<br>
== A2: putting the link into the second column ==


|include = {Some Template}:parm1:[[%PAGE%]]
|table = ,-,The first parameter<br>of the Template Call,Link to the article
|tablerow = bgcolor=#eeffee¦%%,%%
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch = Some Article %
|include = {Some Template}:parm1:[[%PAGE%]]
|include = {Fruit-Infobox}:grows
|table = ,-,The first parameter<br>of the Template Call,Link to the article
|table = class="wikitable sortable",-,The first parameter<br>of the Template Call
|tablerow = bgcolor=#eeffee¦%%,%%
|tablerow = style="background:#eeffee;"¦%%
|count = 5
}}
}}


== A3: just get one column from a template invocation (sortable table)==
== Move page to 2nd column ==


This selects articles in [[:Category:Fruit examples]], it includes the "grows" parameter value from "Fruit-Infobox" template, and the page (with namespace) and title (without namespace) set as link text. The <code>table</code> statement uses <code>-</code> in second position to omit the (automatic) page column. Since the <code>tablerow</code> value corresponds 1:1 to the include statement position, the ''first'' column is styled green, followed by the value carried down using <code>%%</code>.
|include = {Some Template}:parm1

|table = class=sortable,,The first parameter<br>of the Template Call
'''Example:'''<br>
|tablerow = bgcolor=#eeffee¦%%
<pre>
{{#dpl:
|category = Fruit examples
|include = {Fruit-Infobox}:grows:[[%PAGE%|%TITLE%]]
|table = class="wikitable",-,The first parameter<br>of the Template Call,Page
|tablerow = style="background:#eeffee;"¦%%
|count = 5
}}
</pre>

'''Result:'''<br>
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch = Some Article %
|include = {Some Template}:parm1
|include = {Fruit-Infobox}:grows:[[%PAGE%|%TITLE%]]
|table = class=sortable,,The first parameter<br>of the Template Call
|table = class="wikitable",-,The first parameter<br>of the Template Call,Page
|tablerow = bgcolor=#eeffee¦%%
|tablerow = style="background:#eeffee;"¦%%
|count = 5
}}
}}


== A4: just get one column from a template invocation ==
== Move page to 2nd column and format==
This selects articles in [[:Category:Fruit examples]], it includes the "grows" parameter value from "Fruit-Infobox" template, and the page (with namespace). The <code>table</code> statement uses <code>-</code> in second position to omit the (automatic) page column. Since the <code>tablerow</code> value corresponds 1:1 to the include statement position, the ''first'' column is styled green, followed by the value carried down using <code>%%</code>, and then the formatted page title with a tilde <code>~</code> inserted before and after, and made bold.


'''Example:'''<br>
|include = {Some Template}:parm1
<pre>
|table = ,-,The first parameter of the Template Call
|tablerow = bgcolor=#eeffee¦%%
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch = Some Article %
|include = {Some Template}:parm1
|include = {Fruit-Infobox}:grows:%PAGE%
|table = ,-,The first parameter<br>of the Template Call
|table = class="wikitable",-,The first parameter<br>of the Template Call,Page
|tablerow = bgcolor=#eeffee¦%%
|tablerow = %%,'''~[[%PAGE%|%TITLE%]]~'''
|count = 5
}}
}}
</pre>
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''.


'''Result:'''<br>
== B: just get one chapter ==
{{#dpl:
In this example we also demonstrate sorting;
|category = Fruit examples
negative numbers result in descending sort order.
|include = {Fruit-Infobox}:grows:%PAGE%
|table = class="wikitable",-,The first parameter<br>of the Template Call,Page
|tablerow = %%,'''~[[%PAGE%|%TITLE%]]~'''
|count = 5
}}


== Include multiple (different) template's values==
|include = #Chapter X

|table = ,,X
This selects articles in [[:Category:Fruit examples]] whose article names are automatically generated and placed in the first column. It then includes the "Fruit-Infobox" template "grows" parameter value in the second column, and the "Color" template's first <code>1</code> (unnamed parameter) value in the third column. The <code>table=</code> statement sets the table style and headings, the <code>tablerow=</code> statement's <code>%%</code> values correspond 1:1 with the position of the include statement, and allows each cell to be styled (or variables, parser functions, or other DPL3 modules to be used). The last column reuses its value, to both set the font color (because the values are valid [https://www.w3schools.com/cssref/css_colors.asp css color names]) and to display the parameter value text itself.
|tablerow = bgcolor=#ffeeee¦%%

|tablesortcol = -1
'''Notes:'''
* <code>%%</code> values can be reused '''in the same column'''.
* Since <code>%%</code> caries the corresponding 1:1 column values down from the include statement, they can't be reused '''in other columns''', a {{DPL|#dplvar}} can be set in the original column then used elsewhere to move the values between columns.
* '''Templates used multiple times''' on a page are automatically grouped and listed under the same page (the [[Apple]] page uses the "<code><nowiki>{{Color}}</nowiki></code>" twice), since these are grouped under the same page result, the color value <code>%%</code> can only be used to set the style for text color once, which is why the "green" value is red and not green.

'''Example:'''<br>
<pre>
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = #Chapter X
|include ={Fruit-Infobox}:grows,{color}:1
|table = class="wikitable sortable",Page,Fruit-Infobox <br>template "grows" value, Color template "1" <br>(unnamed parameter) value
|table = ,,X
|tablerow = bgcolor=#ffeeee¦%%
|tablerow = style="background:#eeffee;"¦<i>%%</i>,style="color:%%"¦%%
|count = 5
|tablesortcol = -1
}}
}}
</pre>

'''Result:'''<br>
{{#dpl:
|category = Fruit examples
|include ={Fruit-Infobox}:grows,{color}:1
|table = class="wikitable sortable",Page,Fruit-Infobox <br>template "grows" value, Color template "1" <br>(unnamed parameter) value
|tablerow = style="background:#eeffee;"¦%%,style="color:%%"¦%%
|count = 5
}}
{{note|This section and alternative examples are still being considered and may or may not be developed at a later date.}}

== Using a ''surrogate'' template ==


This example uses a surrogate (also known as a phantom) template to specify and/or format a single row of results, using named <code><nowiki>{{{grows|}}}</nowiki></code> or numbered <code><nowiki>{{{1|}}}</nowiki></code> parameters. See the source code of [[Template:Fruit-Infobox.templatevalues‎‎]].
== B2: one chapter, one line per article ==


'''Example:'''<br>
|include = #dummy,#Chapter X
<pre>
|table = ,,,X
|tablerow = ,bgcolor=#ffeeee¦%%
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = #dummy,#Chapter X
|include = {Fruit-Infobox}.templatevalues
|table = ,,,X
|table = ,Page,Grows,Image
|count = 5
|tablerow = ,bgcolor=#ffeeee¦%%
}}
}}
</pre>
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.


'''Result:'''<br>
== C: get two different chapters ==
<pre><nowiki>
|include = #Chapter X,#Chapter Z
|table = ,,X,Z
|tablerow = bgcolor=#ffeeee¦%%,bgcolor=#ffffee¦<i><small>%%</small></i>
</nowiki></pre>
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = {Fruit-Infobox}.templatevalues
|include = #Chapter X,#Chapter Z
|table = ,,X,Z
|table = ,Page,Grows,Image
|count = 5
|tablerow = bgcolor=#ffeeee¦%%,bgcolor=#ffffee¦<i><small>%%</small></i>
}}
}}


== Using multiple ''surrogate'' templates ==
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).


This example uses two surrogate (also known as a phantom) templates to specify and/or format a single row of results, using named <code><nowiki>{{{grows|}}}</nowiki></code> or numbered <code><nowiki>{{{1|}}}</nowiki></code> parameters. See the source code of [[Template:Fruit-Infobox.templatevalues‎‎]] and [[Template:Color.templatevalues‎‎]].
== C2: get two different chapters ==


'''Example:'''<br>
|include=#dummy, #Chapter X, #Chapter Z
<pre>
|table=,,,X,Z
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = {Fruit-Infobox}.templatevalues,{Color}.templatevalues
|include=#dummy, #Chapter X, #Chapter Z
|table = ,Page,Fruit-Infobox<br><code>color=</code>,Fruit-Infobox<br><code>image=</code>,Color<br>(unnamed parameter whose value is specified <code>1</code>
|table=,,,X,Z
|count = 5
}}
}}
</pre>


'''Result:'''<br>
Again we used the trick with the dummy parameter at <tt>include</tt>. As we put a space before the '#Chapter X' we do not even get horizontal separators betrween the chapter texts.
{{#dpl:
|category = Fruit examples
|include = {Fruit-Infobox}.templatevalues,{Color}.templatevalues
|table = ,Page,Fruit-Infobox<br><code>color=</code>,Fruit-Infobox<br><code>image=</code>,Color<br>(unnamed parameter whose value is specified <code>1</code>
|count = 5
}}

== Get 1 section's contents ==
This example includes the content of article's "Notes" section content, for pages in [[:Category:Fruit examples]] that have a section named "Notes" (pages that don't contain this show no content for it). The sort order is set to descending using <code>tablesortcol</code> to cause descending order sorting.

'''Note:''' If any page contains more than one included section, the page name will appear multiple times in the output with each section's contents (as can be seen below).


'''Example:'''<br>
== D: invoke a ''phantom'' template ==
<pre>
|include = {Some Template}.dpl
|table = ,,T1 - p1, T1 - p2
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = {Some Template}.dpl
|include = #notes
|table = ,,T1 - p1, T1 - p2
|table = ,,Notes
|tablerow = style="background:#eeffee;"¦%%
|tablesortcol = -1
|count = 3
}}
}}
</pre>
We need two column headers as ''Template:Some Template.dpl'' produces two columns of output


'''Result:'''<br>
{{#dpl:
|category = Fruit examples
|include = #notes
|table = ,,Notes
|tablerow = style="background:#eeffee;"¦%%
|tablesortcol = -1
|count = 3
}}

== Get 2 section's contents ==
This example includes article's "Notes" and "More" page section contents, for pages in [[:Category:Fruit examples]] that have these sections. The "More" section content is limited to 15 characters <code><nowiki>#More[15]</nowiki></code>. The <code>tablerow</code> statement has <code>%%</code> for each value that needs to be carried down to the its corresponding table row cell. The second is section is formatted in italics, the output count also limited to 3 results.


'''Note:''' If any article contains more than one of any section, the page name will appear in the output the matching number of times the section appears. If farther sections are included, and these don't have multiple instances, their contents are displayed in both rows (it repeats, as can be observed below).
== D1: use template parameters without ''phantom'' template ==
|include = {Some Template}:parm1:parm2[12]
|table = ,,T1 - p1, T1 - p2


'''Example:'''<br>
We delimit the contents of parm2 to 12 characters; note that word boundaries are used
<pre>
to cut the text; so we only get the first two words (=10 characters)
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = {Some Template}:parm1:parm2[12]
|include = #Notes,#More[15]
|table = ,,T1 - p1, T1 - p2
|table = ,,Notes,More
|tablerow = %%,<i>%%</i>
|count = 3
}}
}}
</pre>


'''Result:'''<br>
== D2: invoke a ''phantom'' template ==
|include = #dummy,{Some Template}.dpl2
|table = ,,,Template invocations
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = #dummy,{Some Template}.dpl2
|include = #Notes,#More[15]
|table = ,,,Template invocations
|table = ,,Notes,More
|tablerow = %%,<i>%%</i>
|count = 3
}}
}}
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.


==Dummy section trick==
== E: A combination of all ==

<pre><nowiki>
If a #dummy section is added in the include statement (and an empty corresponding column header is also added), this causes unique behavior when the article results contain multiple sections of the same name. The result is that rather than one line per section being output (along with the page name repeating as was the case in [[#Get 1 section's contents|this example]]), the repeats are instead grouped together, each on a separate line, in one table row. The new lines from subsequent templates have been marked to begin in bold.
|addpagecounter = yes

|include = {Some Template}:parm1:parm2,#Chapter X,#Chapter Z
'''Note:''' Such a trick may not be visually appealing, the other method to achieving this ensures the first column does not repeat because it is specified in a {{DPL|listseparators}} statement, the the other columns can then be formatted and appear normally using a surrogate/phantom template as can be seen in [[Controlling output format/Parameter: multisecseparators (example 3)|multisecseparators (example 3)]].
|table = ,,tpl:parm1,tpl:parm2,Chapter X,Chapter Z,page count

|tablerow = '''%% ''',''%% '',bgcolor=#ffdddd{{!}}%%,bgcolor=#ffffdd{{!}}%%

|format = ,,\n{{!}}bgcolor=#ddddff{{!}}%COUNT%
'''Example:'''<br>
</nowiki></pre>
<pre>
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = #dummy,#More,#Notes,
|addpagecounter = yes
|table = ,Page,,''More'' text,''Notes'' text
|include = {Some Template}:parm1:parm2,#Chapter X,#Chapter Z
|tablerow = ,<i><small>%%</small></i>,<small>%%</small>
|table = ,,tpl:parm1,tpl:parm2,Chapter X,Chapter Z,page count
|count = 5
|tablerow = '''%% ''',''%% '',bgcolor=#ffdddd{{!}}%%,bgcolor=#ffffdd{{!}}%%
|format = ,,\n{{!}}bgcolor=#ddddff{{!}}%COUNT%
}}
}}
</pre>


'''Result:'''<br>
== E2: A combination of all ==

{{#dpl:
|category = Fruit examples
|include = #dummy,#more,#notes,
|table = ,Page,,"More" text,"Notes" text
|tablerow = ,<small>%%</small>,''<small>%%</small>''
|count = 5
}}


==Combination of parameters and sections ==

'''Example:'''<br>
<pre>
{{#dpl:
|category = Fruit examples
|include = {Fruit-Infobox}:grows:image,#Notes[20 more...],#More[20 more...]
|table = class="wikitable",Page,Grows,Image name, Notes, More
|tablerow = <b>%%</b>,<i>%%</i>,%%,%%,%%
|count = 2
|debug=0
}}
</pre>


'''Result:'''<br>
|include=#dummy,{Some Template}.dpl2,#Chapter X,#Chapter Z
|table=,-,,Template Invocations,Chapter X,Chapter Z
{{#dpl:
{{#dpl:
|category = Fruit examples
|titlematch=Some Article %
|include = {Fruit-Infobox}:grows:image,#Notes[20 more...],#More[20 more...]
|include=#dummy,{Some Template}.dpl2,#Chapter X,#Chapter Z
|table = class="wikitable",Page,Grows,Image name, Notes, More
|table=,-,,Template Invocations,Chapter X,Chapter Z
|tablerow = <b>%%</b>,<i>%%</i>,%%,%%,%%
|count = 2
|debug=0
}}
}}


[[Category:Miscellaneous examples]]
Note the '-' as the second parameter for the <tt>table</tt> arguments.
[[Category:DPL Example|{{PAGENAME}}]]

Revision as of 07:09, 12 April 2022

The following tests explain how to use the table parameter.

Include 1 template value

This selects articles in Category:Fruit examples whose article names are automatically generated and placed in the first column. It then includes the "Fruit-Infobox" template "grows" parameter value, which appears in the second column, if the article has a value for grows= on its page (otherwise this cell displays empty). The table= statement sets the table styles (if set) before the first comma, and then sets the header columns text. The tablerow= statement corresponds 1:1 with the position of the include statement ("grows" in the second column) so it colors the second column green and then displays the value carried down %%. The results are limited to a count of 5.

Example:

{{#dpl:
|category   = Fruit examples
|include    = {Fruit-Infobox}:grows
|table      = class="wikitable sortable",Page,The first parameter<br>of the Template Call
|tablerow   = style="background:#eeffee;"¦%%
|count      = 5
}}

Result:
{{#dpl: |category = Fruit examples |include = {Fruit-Infobox}:grows |table = class="wikitable sortable",Page,The first parameter
of the Template Call |tablerow = style="background:#eeffee;"¦%% |count = 5 }}

Omit (automatic) first column

This selects articles in Category:Fruit examples, it includes the "grows" parameter value from "Fruit-Infobox" template. The table statement uses ,-, in second position to omit the (automatic) page column, the "grows" value appears there instead. Since the tablerow value corresponds 1:1 to the include statement position, the first column is styled green, followed by the value carried down using %%.

Example:

{{#dpl:
|category      = Fruit examples
|include       = {Fruit-Infobox}:grows
|table         = class="wikitable sortable",-,The first parameter<br>of the Template Call
|tablerow      = style="background:#eeffee;"¦%%
|count         = 5
}}

Result:

{{#dpl: |category = Fruit examples |include = {Fruit-Infobox}:grows |table = class="wikitable sortable",-,The first parameter
of the Template Call |tablerow = style="background:#eeffee;"¦%% |count = 5 }}

Move page to 2nd column

This selects articles in Category:Fruit examples, it includes the "grows" parameter value from "Fruit-Infobox" template, and the page (with namespace) and title (without namespace) set as link text. The table statement uses - in second position to omit the (automatic) page column. Since the tablerow value corresponds 1:1 to the include statement position, the first column is styled green, followed by the value carried down using %%.

Example:

{{#dpl:
|category      = Fruit examples
|include       = {Fruit-Infobox}:grows:[[%PAGE%|%TITLE%]]
|table         =  class="wikitable",-,The first parameter<br>of the Template Call,Page
|tablerow      = style="background:#eeffee;"¦%%
|count         = 5
}}

Result:
{{#dpl: |category = Fruit examples |include = {Fruit-Infobox}:grows:%TITLE% |table = class="wikitable",-,The first parameter
of the Template Call,Page |tablerow = style="background:#eeffee;"¦%% |count = 5 }}

Move page to 2nd column and format

This selects articles in Category:Fruit examples, it includes the "grows" parameter value from "Fruit-Infobox" template, and the page (with namespace). The table statement uses - in second position to omit the (automatic) page column. Since the tablerow value corresponds 1:1 to the include statement position, the first column is styled green, followed by the value carried down using %%, and then the formatted page title with a tilde ~ inserted before and after, and made bold.

Example:

{{#dpl:
|category      = Fruit examples
|include       = {Fruit-Infobox}:grows:%PAGE%
|table         =  class="wikitable",-,The first parameter<br>of the Template Call,Page
|tablerow      = %%,'''~[[%PAGE%|%TITLE%]]~'''
|count         = 5
}}

Result:
{{#dpl: |category = Fruit examples |include = {Fruit-Infobox}:grows:%PAGE% |table = class="wikitable",-,The first parameter
of the Template Call,Page |tablerow = %%,~%TITLE%~ |count = 5 }}

Include multiple (different) template's values

This selects articles in Category:Fruit examples whose article names are automatically generated and placed in the first column. It then includes the "Fruit-Infobox" template "grows" parameter value in the second column, and the "Color" template's first 1 (unnamed parameter) value in the third column. The table= statement sets the table style and headings, the tablerow= statement's %% values correspond 1:1 with the position of the include statement, and allows each cell to be styled (or variables, parser functions, or other DPL3 modules to be used). The last column reuses its value, to both set the font color (because the values are valid css color names) and to display the parameter value text itself.

Notes:

  • %% values can be reused in the same column.
  • Since %% caries the corresponding 1:1 column values down from the include statement, they can't be reused in other columns, a #dplvar can be set in the original column then used elsewhere to move the values between columns.
  • Templates used multiple times on a page are automatically grouped and listed under the same page (the Apple page uses the "{{Color}}" twice), since these are grouped under the same page result, the color value %% can only be used to set the style for text color once, which is why the "green" value is red and not green.

Example:

{{#dpl:
|category   = Fruit examples
|include    ={Fruit-Infobox}:grows,{color}:1
|table      = class="wikitable sortable",Page,Fruit-Infobox <br>template "grows" value, Color template "1" <br>(unnamed parameter) value 
|tablerow   = style="background:#eeffee;"¦<i>%%</i>,style="color:%%"¦%%
|count      = 5
}}

Result:
{{#dpl: |category = Fruit examples |include ={Fruit-Infobox}:grows,{color}:1 |table = class="wikitable sortable",Page,Fruit-Infobox
template "grows" value, Color template "1"
(unnamed parameter) value |tablerow = style="background:#eeffee;"¦%%,style="color:%%"¦%% |count = 5 }}

This section and alternative examples are still being considered and may or may not be developed at a later date.

Using a surrogate template

This example uses a surrogate (also known as a phantom) template to specify and/or format a single row of results, using named {{{grows|}}} or numbered {{{1|}}} parameters. See the source code of Template:Fruit-Infobox.templatevalues‎‎.

Example:

{{#dpl:
|category   = Fruit examples
|include    = {Fruit-Infobox}.templatevalues
|table      = ,Page,Grows,Image
|count      = 5
}}

Result:
{{#dpl: |category = Fruit examples |include = {Fruit-Infobox}.templatevalues |table = ,Page,Grows,Image |count = 5 }}

Using multiple surrogate templates

This example uses two surrogate (also known as a phantom) templates to specify and/or format a single row of results, using named {{{grows|}}} or numbered {{{1|}}} parameters. See the source code of Template:Fruit-Infobox.templatevalues‎‎ and Template:Color.templatevalues‎‎.

Example:

{{#dpl:
|category   = Fruit examples
|include    = {Fruit-Infobox}.templatevalues,{Color}.templatevalues
|table      = ,Page,Fruit-Infobox<br><code>color=</code>,Fruit-Infobox<br><code>image=</code>,Color<br>(unnamed parameter whose value is specified <code>1</code>
|count      = 5
}}

Result:
{{#dpl: |category = Fruit examples |include = {Fruit-Infobox}.templatevalues,{Color}.templatevalues |table = ,Page,Fruit-Infobox
color=,Fruit-Infobox
image=,Color
(unnamed parameter whose value is specified 1 |count = 5 }}

Get 1 section's contents

This example includes the content of article's "Notes" section content, for pages in Category:Fruit examples that have a section named "Notes" (pages that don't contain this show no content for it). The sort order is set to descending using tablesortcol to cause descending order sorting.

Note: If any page contains more than one included section, the page name will appear multiple times in the output with each section's contents (as can be seen below).

Example:

{{#dpl:
|category   = Fruit examples
|include    = #notes
|table    = ,,Notes
|tablerow = style="background:#eeffee;"¦%%
|tablesortcol = -1
|count         = 3
}}

Result:
{{#dpl: |category = Fruit examples |include = #notes |table = ,,Notes |tablerow = style="background:#eeffee;"¦%% |tablesortcol = -1 |count = 3 }}

Get 2 section's contents

This example includes article's "Notes" and "More" page section contents, for pages in Category:Fruit examples that have these sections. The "More" section content is limited to 15 characters #More[15]. The tablerow statement has %% for each value that needs to be carried down to the its corresponding table row cell. The second is section is formatted in italics, the output count also limited to 3 results.

Note: If any article contains more than one of any section, the page name will appear in the output the matching number of times the section appears. If farther sections are included, and these don't have multiple instances, their contents are displayed in both rows (it repeats, as can be observed below).

Example:

{{#dpl:
|category   = Fruit examples
|include    = #Notes,#More[15]
|table      = ,,Notes,More
|tablerow   = %%,<i>%%</i>
|count      = 3
}}

Result:
{{#dpl: |category = Fruit examples |include = #Notes,#More[15] |table = ,,Notes,More |tablerow = %%,%% |count = 3 }}

Dummy section trick

If a #dummy section is added in the include statement (and an empty corresponding column header is also added), this causes unique behavior when the article results contain multiple sections of the same name. The result is that rather than one line per section being output (along with the page name repeating as was the case in this example), the repeats are instead grouped together, each on a separate line, in one table row. The new lines from subsequent templates have been marked to begin in bold.

Note: Such a trick may not be visually appealing, the other method to achieving this ensures the first column does not repeat because it is specified in a listseparators statement, the the other columns can then be formatted and appear normally using a surrogate/phantom template as can be seen in multisecseparators (example 3).


Example:

{{#dpl:
|category   = Fruit examples
|include    = #dummy,#More,#Notes,
|table      = ,Page,,''More'' text,''Notes'' text
|tablerow   = ,<i><small>%%</small></i>,<small>%%</small>
|count      = 5
}}

Result:

{{#dpl: |category = Fruit examples |include = #dummy,#more,#notes, |table = ,Page,,"More" text,"Notes" text |tablerow = ,%%,%% |count = 5 }}


Combination of parameters and sections

Example:

{{#dpl:
|category   = Fruit examples
|include    = {Fruit-Infobox}:grows:image,#Notes[20 more...],#More[20 more...]
|table      = class="wikitable",Page,Grows,Image name, Notes, More
|tablerow   = <b>%%</b>,<i>%%</i>,%%,%%,%%
|count = 2
|debug=0
}}

Result:
{{#dpl: |category = Fruit examples |include = {Fruit-Infobox}:grows:image,#Notes[20 more...],#More[20 more...] |table = class="wikitable",Page,Grows,Image name, Notes, More |tablerow = %%,%%,%%,%%,%% |count = 2 |debug=0 }}