Generating tabular output (examples)

The following tests explain how to use the parameter.

Include 1 template value
This selects articles in Category:Fruit examples whose article names are automatically generated and placed in the first column (unless chosen to be omitted). It then includes the "Fruit-Infobox" template "grows" parameter value, for each article in the result set, in the second column. The  statement sets the table styles (if desired) before the first comma, and then sets the header column text. The  statement can be used to format some or all of the output, but starting after the page name, so it corresponds to the second columnso it colors the second column green;   is used to position the value after the formatting. The results are limited to a count of 5.

Note: The  in   allows precise positioning of the column value, inside whatever formatting you want to apply.

Example:

Result:

Omit (automatic) first column
This selects articles in Category:Fruit examples, it includes the "grows" parameter value from "Fruit-Infobox" template. The  statement formats the table as "wikitable" and "sortable" and uses   in second position to omit the first (automatic) page column; the "grows" value now appears in the first column. With the first column left off,  corresponds 1:1 to the include statement, so the first column is styled green using   to position the value after the styling.

Note: If the page name is omitted, and one of the "grows" cells is empty (its page doesn't have a value for "grows" parameter), it appears as an empty row in the table.

Example:

Result:

Move page to 2nd column
This selects articles in Category:Fruit examples, it includes the "grows" parameter value from the "Fruit-Infobox" template, and the page name ( gives name with namespace, if applicable) which is linked, using   (page name without namespace) as the link text. The  statement formats the table, then uses   in the second position to omit the first (automatic) page column. With the page column omitted, the  formatting corresponds 1:1 to the include statement and the first column containing the "grows" parameter value is displayed using. The last column uses  position the value for bold formatting.

Note: Linking a page name can be done in an  statement, though magic words, parser functions, and other formatting needs to be done in the tablerow statement.

Example:

Result:

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  statement uses   in second position to omit the (automatic) page column which makes the   value corresponds 1:1 to the include statement position. has no formatting set for the first column, so its content is displayed as-is from the "grows"  statement, and in the second column the page (and title) is linked with italic formatting applied.

Example:

Result:

Include multiple template values
Multiple template parameter values can be added, these can also be formatted in the  statement. This example selects articles in Category:Fruit examples and includes the page title, the "image" parameter value, and the "grows" parameter value. The  statement formats the table, omits the regular (automatic) linked page name first column (so it can be manually inserted without link the   line) and then creates the page headers. The  line formats the plain (unlinked) title in italics, followed by "image" parameter value formatted as a rendered image at 30 pixels wide, and the unformatted "grows" parameter value is displayed last.

Example:

Result:

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 (numbered parameter)  value in the third column. The  statement sets the table style and headings, the   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 and display the parameter value text itself.

Example:

Notes:
 * values can be reused in the same column.
 * Since  essentially "caries" the corresponding 1:1 column values down from the   statement to apply formatting to, they can't be reused in other columns in a  statement without the use of  to move the values between columns (though a surrogate template can better enable moving column values to other columns in the same result row).
 * Templates used multiple times on a page, have their values automatically grouped and listed under the same page line (the Apple page uses the " " template twice, so two color names appear), 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.
 * If you need the contents of templates reused on the same page to be displayed on separate lines, see the example of how this is done instead of   (by using a combination of ,  ,  , and   instead.

Result:

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  or   numbered parameters. See the source code of Template:Fruit-Infobox.templatevalues‎‎.

See for more information on surrogate templates.

Example:

Result:

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  or   numbered parameters. See the source code of Template:Fruit-Infobox.templatevalues‎‎ and Template:Color.templatevalues‎‎.

See for more information on surrogate templates.

Example:

Result:

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

Result:

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. The  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:

Result:

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

Result:

Combination of parameters and sections
Example:

Result: