Controlling output format

You can select one of several default formats or define your own format ; output can be grouped in columns or rows.

In the examples that follow, the DPL output has been kept small to reduce page load time and page size, most notably using,  ,  , and.

General approach to output formatting
The general approach to output formatting is two-fold:


 * 1) There are a couple of simple predefined output formats which generate lists of articles.
 * You will understand their meaning directly from reading.
 * 1) There is a mode called  which puts complete control into your hands.
 * This is somewhat complicated.

While the standard output formats are meant to be used for fast generation of simple page lists, the approach aims at transcluding contents from other pages and requires some effort to understand. There is a system of three tags which are used to enclose (a) the whole output, (b) each item, (c) each transcluded section of an item. A fourth tag is used to separate values between items of one section which occur more than once.

We assume that we have two documents which use templates and  with varying arguments; while  is being used once within each document,  is used several times. In very short notation, the structure might look as follows:  A: x(a) y(3) y(5) B: x(b) y(4) y(1) y(2)

The following DPL parameters are used to define a set of tags which are used to construct the output: The arguments of the above statements can contain references to . So sec-1-start might contain a reference like  to output the page name. See for more details on variable substitution.

Now think of the following page inclusion statement:  includepage={x}.dpl,{y}.dpl

The output will then look like this:  liststart itemstart sec-1-start x.dpl(a) sec-1-end sec-2-start y.dpl(3) multi-sep y.dpl(5) sec-2-end itemend itemstart sec-1-start x.dpl(b) sec-1-end sec-2-start y.dpl(4) multi-sep y.dpl(1) multi-sep y.dpl(2) sec-2-end itemend listend

Assuming that the tags (,, etc.) contain wiki syntax for table definitions and defines a horizontal line, the output might look like this:  +--+-+ |      |          | y.dpl(3) | | A   | x.dpl(a) |      | |     |          | y.dpl(5) | +--+--+--+ |      |          | y.dpl(4) | |     |          |      |  |  B   | x.dpl(b) | y.dpl(1) | |     |          |      |  |      |          | y.dpl(2) | +--+--+--+

In some situations, however, you may want to create an output table where each of the calls of template is used to create a separate output row. Using a sortable table you could then easily rearrange the output.  +--+-+      +--+-+  |  A   | x.dpl(a) | y.dpl(1) |       |  B   | x.dpl(b) | y.dpl(1) | +--+-+      +--+-+  |  A   | x.dpl(a) | y.dpl(2) |       |  B   | x.dpl(b) | y.dpl(2) | +--+-+      +--+-+  |  B   | x.dpl(b) | y.dpl(3) |       |  A   | x.dpl(a) | y.dpl(3) | +--+-+      +--+-+  |  B   | x.dpl(b) | y.dpl(4) |       |  A   | x.dpl(a) | y.dpl(4) | +--+-+      +--+-+  |  B   | x.dpl(b) | y.dpl(5  |       |  B   | x.dpl(b) | y.dpl(5) |  +--+-+       +--+-+

There is a special parameter called  which you can use to mark one section of your   statement as "dominant" (in our example: "dominantsection=2" as  is the second argument of our   statement). You can only have one dominant section in a DPL statement. Marking a section as "dominant" only makes sense if you have multiple calls of the same template (or multiple chapters with the same heading) in your documents. Each piece of content in the dominant section will generate an individual output row with the values of all other columns being repeated.

As all of the above is difficult to understand, there are additional DPL commands which make it fairly easy to create tabular output.

mode
Syntax:

where modename can be one of:


 * — outputs an unordered list — HTML tag — (default).
 * — outputs an ordered list — HTML tag.
 * — outputs a list using newlines and HTML tags to separate each item.
 * — outputs a list using symbols defined by the  parameter to separate items.
 * — outputs resulting articles in a way category pages are shown (you must use  with one of:   /   /   /   with this option).
 * — will leave output control completely to the user; see parameters  and  ; in this mode, DPL offers built-in variables which must be referenced in the output format description provided by the user.   is quite important to have complete control over the output.

For advanced use of DPL, it is important to understand. Note that this mode is automatically implied when  or   are used.

mode 'ordered', 'unordered', 'none'
Example:

For space and comparison reasons, this example has been modified and put inside wikitable syntax to display the results side-by-side, rather than one after the other. See the actual example page for the proper (simplified) result, or test it in a sandbox (link at the right). The below examples create abbreviated lists of articles in Category:Fruit examples, each formatted either using an ordered list (numbered), and unordered list (bulleted), or the none list style (no list item markers).

mode 'category'
Example:

Note: You must use  with one of:   /   /   /   with this option.

inlinetext
Syntax: , where wikitext is the text to be set.

The default formatting is  which results in   except when   where   is empty by default.

Notes:
 * If you want normal "breaking spaces" (and not the NON-breaking spaces) you should use.
 * Extra whitespaces are stripped by DPL from the beginning and end of wikitext. If you want to show one or multiple spaces, use one or multiple, or use 'nowiki' tags   which has the same effect as.
 * Bullets can be displayed with either  or *.

Example:

Result:

format
Syntax:

Startall, Start, End and Endall are wiki tags used to separate the list items.
 * Startall and Endall define an outer frame for the whole list.
 * Start and End build an inner frame for each article item.

Notes:
 * is an alias for.
 * The  command is very flexible, but somewhat complicated. If you want to create tabular output, also see the   command.
 * Because wiki syntax depends on newline characters,  or   must be used to explicitly insert newline characters into the output.
 * A bullet point list in wiki syntax is defined by a  at the beginning of a line — therefore   or   must be used.
 * A numbered list in wiki syntax is defined by a  at the beginning of a line — therefore   or   must be used.

Example: For space and comparison reasons, this example has been modified and put inside wikitable syntax to display the results side-by-side, rather than one after the other. See the actual example page for the proper (simplified) result, or test it in a sandbox (link at the right). The classical default output of DPL, an unordered (bulleted) list, can be produced by using a default statement (first example and result). It can also be created using  with the following statements (last example and result). This selects pages that have "ntries" in the title, it excludes pages that have "f" in the title, and it also excludes subpages. The  statement's ,  , and   arguments are empty, only   is used to manually define a bulleted list followed by the liked page name, which is then applied to each row of output.

Example:

Result:

Notes:
 * You can also use HTML syntax for the tags, although this is discouraged.
 * format  = ,%PAGE%,,

The  parameter can be used to create a table using wiki syntax (note that the parser function syntax   invocation method requires the pipe   characters to be replaced by broken pipe  . Again, as wiki syntax depends on newline characters,   or   must be used to explicitly insert newline characters into the output.

Example:

Result:

Notes:
 * position of the  syntax starts and formats a row of output, which is then applied to each item in the result set.
 * In the case of results outside of the Main namespace, such as in the "Category" namespace, if "Category:" is not desired in the page title/link,  can be used instead.
 * The  parameter, in combination with   and the  /  parameter, can also be used to output table syntax.

Image galleries can also be produced using the format syntax.

Example:

Result:

Variables
As we want to be able to control output completely, we reference article names and other possible output by special :  Note: The above variables will be replaced by the corresponding values if they occur within Start or End or within the corresponding tags of the  parameter. 

secseparators
Syntax:

or

In the first syntax variant, specify pairs of tags which correspond to the statement. and are HTML strings or wiki tags which will be put around each transcluded section (see ).

In the second syntax variant, specify just one element which will then be used as for all sections; in this case the second tag  will be empty for all transcluded sections.

Symbolic replacements of etc. take place as described in. In addition, the variable can be used to refer to the section found (works only for chapter headings).

If the same section occurs more than once in an article (or an article includes the same template more than once) all such occurences will be transcluded as a block and the tags will only be put once around the whole block (but see ).

Example:

As mentioned above, a single element can be used in the  statement to apply this as a start tag to all transcluded sections; so it could have also been written as shown in the the example below.

Example:

multisecseparators
Syntax:

The tags correspond to the transcluded section (see ).

Symbolic replacements of etc. take place as described in. In addition, the variable can be used to refer to the section found (works only for chapter headings). It will give you the precise name of each heading, even if you used a regular expression (double ##) in the include statement.

If an article uses the same template more than once, you will get all references with as a separator.

Example:

Result:

Values cannot be formatted within, as formatting can only occur in formatting statements (this can be done in   or  , and  ). Variables can be omitted from the, and instead be placed in these formatting statements, for further formatting.

We can achieve some field formatting by changing some of the above dpl statements:

Example:

Example:

Formatting handled by a surrogate (also known as phantom) template (e.g., Template:DPL parameter.surrogateexample‎‎) will apply to both and.

If separate formatting is required, it needs to be assigned to their respective parameters (as shown in the surrogate, and in the example above if you click "View result"). In the surrogate and in the result, you can see a link was applied to the second column in addition to the first, this required the use of a surrogate, though there are simpler ways to accomplish a task as basic as this, see the and  parameters for more information).

dominantsection
Syntax:

between 1 and the number of arguments in your  statement

If there is only 0 or 1 piece of contents for the dominant section, you will see no difference from normal DPL behaviour.

See the explanations at the top of this document to understand the meaning of dominantsection.

Note: Using  together with   may lead to strange result formatting.

table
Syntax:

The  parameter is a shortcut which implicitly sets certain values for other DPL parameters, namely ,   /  ,  , and.

The layout is less flexible than the individual use of all of the above parameters, but will probably be sufficient often, especially when used together with.

If you use  in a DPL statement, it does not make sense to use one of the other options mentioned because their values will be overwritten without notice. There is one exception to this rule: It can make sense to specify the THIRD argument for  in combination with. Therefore, this parameter is NOT overwritten by the  command. The third argument can be used to output meta data like,   etc., as columns in an output table. If you want to do so, the third parameter must contain wiki syntax for output columns like this: include = {some template}:parm1,#some heading table  =,,tplparm,chapter,#hits format =,,\n%COUNT% Do not forget to escape the  symbol if your DPL statement uses parser function syntax. You will get a table which contains template parameters, chapter contents and the usage counter as a third column. Meta data can only be placed AFTER normal contents, as we use the THIRD parameter of the  statement.

The use of  requires an   statement which should, for reasons of readability, directly precede the   statement). Each argument of the   statement will produce one or more columns in the output table described in the   statement.

table expects a comma-separated list of arguments:


 * The first argument assigns general properties for the table.
 * It is recommended to make a CSS reference here, using something like, or   if mytable is defined in the Mediawiki:Common.css document.
 * is the default value if left empty.


 * The second parameter is the headline for the first column.
 * The first column of table output is automatically generated, it will contain a link to the article unless intentionally suppressed with a hypen.
 * You can manually create a hyperlink to the article in any other column instead using, in a   statement, or in a surrogate (also known as phantom) template.
 * If no header text is specified in second position, "Content page" appears.


 * All subsequent arguments are column headings, which correspond to the arguments of the  parameter. If you call a surrogate template (like ) in the   statement, you will need to provide as many headlines as the surrogate template produces columns.


 * will be set to userformat.


 * will be configured to produce wiki syntax which defines a table.


 * will be configured to produce wiki syntax which creates a table row. The first column will always contain a hyperlink to the article of the query result (except you set the link header to '-' as described above.


 * will be configured to produce wiki syntax which creates another table row for multiple occurrences of the first  argument. For all other arguments, a linebreak will be used if we are dealing with template parameters and a horizontal separation line will be used when dealing with chapter contents. The background for this is the following: If you have an article which calls the same template several times, you may want to have a table where each template invocation becomes a row in your table.

Example:

Result:

Example:

Result:

When using surrogate templates (i.e., templates that format a single row of output, called during DPL execution, and then applied by DPL to subsequent rows), they must be written to produce output according to wiki table syntax. The  parameter already creates the beginning and end of a table, so when entering such a template, we are already at the beginning of a column (i.e., a preceding line with a  has already been put into the output stream). So, start directly with the contents of the first column. To add more columns, use a on a separate line.

Example:

some output for the first column: |  some output for the next column: |  some output for the next column:

It may sound complicated, but is a huge improvement compared to the native use of,  ,   and.

A typical DPL statement using the parameter would contain: include =                           #Chapter X,   {T1}:param1   ,#Chapter Y,{T2}.dpl table  = class="sortable", Article,      X   , Template param1 ,     Y    ,T2-a T2-b Note that we have written the above statement in a way to show the correspondence between  and. You can see the first two arguments define the table characteristics and then first column (for the hyperlink to the article) and headline. Then follow headlines for each argument of. Note that there are TWO headlines which correspond to the last argument of the  statement (assuming that Template:T2.dpl outputs TWO columns). Template:T2 itself might have more or less than 2 arguments — it only matters how many columns are output by Template:T2.dpl).

Example:

Result:

See: the collection of Generating tabular output (examples) for more table examples, and also  for more information on surrogate template use.

tablerow
Syntax:

where columnDefinition uses the symbol  to precisely position content included by an   statement, within wikitext formatting code.

When it comes to simple tables using, an   statement first tells DPL3 what content to include in each column of a table, the   statement sets corresponding table syntax, styles, separators, table headers, and also determines if the first (automatically generated) column is included or suppressed. The job of the  is to precisely position the column values   of the corresponding , within some supplied formatting for a single row of output. Whatever is supplied for formatting is then re-applied to every row of output.

When you define the formatting, you can start with cell styles/attributes like  (followed by the value  ) or skip such styles and just add the value. You must specify all columns, meaning you must have as many entries in the  statement as there are columns in your table. Skipping a column would suppress output for that column completely.

Example:

Result:

Notes:
 * You can add a leading  or   to make sure that the field contents are displayed correctly if it contains wiki syntax that depends on line breaks (e.g., numbered list).
 * See Generating tabular output (examples) for many more examples of  use (and other methods of generating tabular data).

tablesortcol
Syntax:

number is the position of the column that shall be used as sortkey when the result is initially displayed.
 * column numbering starts with 1;
 * means do not sort; this is the default.
 * Negative numbers are used to sort in descending order; e.g., -3 would sort according to the third column in descending order.
 * Note that the rest of the row after the selected column will also be part of the sortkey; so the contents of successive columns may serve as a secondary sort criterion if there are identical values in the selected column.
 * Also note that the whole column contents is taken; this may include hidden contents or markup sequences if you used column formatting commands. For the same reason, you cannot expect numeric contents to be sorted 'numerically'—sorting will always be alphabetical.
 * you can, of course, use something like  or   together with  . The difference is that ..
 * interactive sorting only works after the article has been initially displayed
 * interactive sorting tries to guess the content type of a column and sorts according to that (date, number, string)
 * If you do not use  the output order of your table rows will depend on the sort order by which the articles were analyzed. That order depends on other DPL commands like  . The default is "alphabetically by title". So, without   you get the table rows in alphabetical sequence of the article names where they come from. With   you can order them by the column contents itself.

headingmode
Syntax:

where modename can be one of:
 * — outputs an ordered list — HTML tag
 * — outputs an unordered list — HTML tag
 * — outputs a definition list — HTML tag
 * — headings are not displayed, no heading — (default, needs not be set)
 * — outputs sections — HTML tags
 * — outputs sections — HTML tags
 * — outputs sections — HTML tags
 * — outputs sections — HTML tags
 * — outputs sections — HTML tags

Example:

Result:

, which governs the mode of only headings, can also be combined with  or , which can number or bullet the articles under those headings.

Example:

Result:

Note:  can be used with multi-column output, but the length of the columns may in this case vary more than you would expect.

headingcount
Syntax:

Note: (default is, it need not be set)

listattr
Syntax:

Example:

If there is one page output for each category, the HTML structure output is:

Result:

itemattr
Syntax:

Note: An example of this parameter's use can be seen in.

hlistattr
Syntax:

Example: These examples compare, , and

See also.

hitemattr
Syntax:

Example:

userdateformat
Syntax:

The formatstring may contain letters like "y,Y,m,M,d,D,h,H,i,I,s" for year, month day. Other characters are printed as they are. See the documentation for PHP function date for more details. The userdateformat applies to all date/time fields, see the parameters:,  ,.

Example:

userdateformat=Y-m-d (D)

Default:

By default, DPL uses "Y-m-d H:i:s" to display date and time. Note that MediaWiki stores all dates/times in UTC format. When displaying a time stamp, DPL will translate it according to
 * 1) the timezone preference (difference to UTC/GMT) given by the user in his user settings.
 * 2) if no preference is given and for all anonymous users, the local time on the server will be used.

So you will either see a time based on your local time (browser based) or based on the timezone in which the wiki server is running.

The same kind of translation applies to dates you specify when selecting articles by revision date/time.

shownamespace
Syntax:

Example:

category     = Fruit examples namespace    = Fruit examples_talk shownamespace = false

This list will output all Talk pages in Category:Fruit examples‏‎, listed without the 'Fruit examples talk:' prepended to page names. The namespace 'Talk' refers to talk pages within the main namespace; all other talk namespaces, such as 'Help' or 'Guide' talk pages, would need the format 'namespace_talk'. Only talk pages that have been added to the category (by placing on the talk page) will be listed.

category     = Fruit examples namespace    = Fruit examples_talk shownamespace = false

Note: In  there is a different way to decide whether you want to output the title with or without namespace. In  two built-in variables are provided which contain the page name including the namespace  and the base title name.

escapelinks
Syntax:

Note: You can use this parameter to show images; another way to do this is to use the gallery extension with DPL; there is an example here.

titlemaxlength
Syntax:

replaceintitle
Syntax:

The search for argument must be an expression which can be used in a PHP preg_replace function call.

to remove the string "demo" in article names, you must write

Note that standard regexp rules apply. The regexp must start with a non-alphanumeric character -- but not with a backslash! It is good habit to use a '/' if this character is not needed within the regexp itself. Read the PHP manual to understand the details of regular expressions.

columns
Syntax:

Example:

category	 = Fruit examples nottitlematch	 = %ran% includesubpages = false columns	 = 3 rowcolformat	 = width=100% count		 = 6

Simply displays non-DPL articles and subcategories in Category:Fruit examples‏‎ that don't have a title that matches "ran" (like Orange), arranged in 3 columns ( is used to make the table width 100%).

Result: category	 = Fruit examples nottitlematch	 = %ran% includesubpages = false columns	 = 3 rowcolformat	 = width=100% count		 = 6 Note: is currently bugged (possible combatibility issue between Mediawiki 1.31.2 and DPL3 v3.3.3). For a 3-column dpl, css can be used to achieve the desired results: category	 = Help nottitlematch	 = %DPL% includesubpages = false columns	 = 3 rowcolformat	 = width=100% count		 = 6 category		 = Help nottitlematch	 = %DPL% includesubpages = false columns		 = 3 rowcolformat	 = width=100% count			 = 6

More complex example:

In "=userformat" the outer tags from will be repeated for each column.

category	 = Fruit examples‏‎ nottitlematch	 = %ran% includesubpages = false addpagesize	 = true ordermethod	 = size listseparators = {|class="wikitable sortable" id=2\n!Rank\n!Article\n!Bytes\n|-,\n|%NR%.\n|%PAGE%\n|style="text-align:right;"|%SIZE%,\n|-,\n|} columns	 = 2 count		 = 6

This output contains a list of the largest non-DPL articles in Category:Fruit examples‏‎ that don't have a title that matches "ran" (like Orange). Each column consists of a table which has itself three columns: rank, article name and size.

category	 = Fruit examples‏‎ nottitlematch	 = %ran% includesubpages = false addpagesize	 = true ordermethod	 = size listseparators = {|class="wikitable sortable" id=2\n!Rank\n!Article\n!Bytes\n|-,\n|%NR%.\n|%PAGE%\n|style="text-align:right;"|%SIZE%,\n|-,\n|} columns	 = 2 count		 = 6

rows
Syntax:

In "=userformat", the outer tags from  will be repeated for each column. Thus, you can create long lists where the table heading is repeated from time to time.

Example:

category	 = Fruit examples‏‎ nottitlematch	 = %ran% includesubpages = false addpagesize	 = true ordermethod	 = size listseparators = {|class="wikitable sortable" id=2\n!Rank\n!Article\n!Bytes\n|-,\n|%NR%.\n|%PAGE%\n|style="text-align:right;"|%SIZE%,\n|-,\n|} rows		 = 2 count		 = 6

The output will contain a list of the largest articles in Category:Fruit examples‏‎ that don't have a title that matches "ran" (like Orange), arranged in two rows (dividing the list of lines equally into 2). Each row consists of a table which has itself three columns: rank, article name, and size.

Result:

category	 = Fruit examples‏‎ nottitlematch	 = %ran% includesubpages = false addpagesize	 = true ordermethod	 = size listseparators = {|class="wikitable sortable" id=2\n!Rank\n!Article\n!Bytes\n|-,\n|%NR%.\n|%PAGE%\n|style="text-align:right;"|%SIZE%,\n|-,\n|} rows		 = 2 count		 = 6

rowsize
Syntax:

In  the outer tags from   will be repeated after each group of   output lines. Thus you can create long lists where the table heading is repeated in regular intervals.

Example:

category	 = Fruit examples‏‎ nottitlematch	 = %ran% includesubpages = false addpagesize	 = true ordermethod	 = size listseparators = {|class="wikitable sortable" id=2\n!Rank\n!width=200px|Article\n!Bytes\n|-,\n|%NR%.\n|%PAGE%\n|style="text-align:right;"|%SIZE%,\n|-,\n|} rowsize	 = 3 count		 = 6

The output will contain a list of all articles in Category:Fruit examples‏‎ that don't have a title that matches "ran" (like Orange). After each group of 3 entries (article names) the table heading will be repeated. It may be useful to set the width of the column with the article names explicitly, so that the tables in each row have equal width. category	 = Fruit examples‏‎ nottitlematch	 = %ran% includesubpages = false addpagesize	 = true ordermethod	 = size listseparators = {|class="wikitable sortable" id=2\n!Rank\n!width=200px|Article\n!Bytes\n|-,\n|%NR%.\n|%PAGE%\n|style="text-align:right;"|%SIZE%,\n|-,\n|} rowsize	 = 3 count		 = 6

rowcolformat
Syntax:

Example:

category	 = Help nottitlematch	 = %DPL% includesubpages = false columns	 = 3 rowcolformat	 = cellspacing=20 count		 = 6

There will be more space around the columns than normal. See above for another example. category		 = Help nottitlematch	 = %DPL% includesubpages = false columns		 = 3 rowcolformat	 = cellspacing=20 count			 = 6

The ideal way to use  is to assign a CSS class to your DPL table, which has been defined in your MediaWiki:Common.css article.

Example:

category	 = Help nottitlematch	 = %DPL% includesubpages = false columns	 = 3 rowcolformat	 = class="dpl3columns" count		 = 6

In your Common.css article, you might have written something like

table.dpl3columns td { background: #f2f2f2; padding: 0.5em; border: 3px; width: 33%; }