公告

CSS模板 在bwiki中 正式启用!请根据CSS使用指南配置页面CSS!

我们正在对全站css和js进行施工,期间可能出现页面内容显示不正常的情况,敬请谅解。

全站通知:

公共沙盒

阅读

    

2025-02-05更新

    

最新编辑:Iopkjhjjjh

阅读:

  

更新日期:2025-02-05

  

最新编辑:Iopkjhjjjh

来自Backrooms后室WIKI_BWIKI_哔哩哔哩
(重定向自公共沙盒
跳到导航 跳到搜索
页面贡献者 :
Iopkjhjjjh
MC_棕熊不是白熊

欢迎来到本wiki的公共沙盒,你可以在这里测试代码,或文章的写法。折腾可随意,只要别违法。 注意:所有人都可以编辑本页面,如果您不想自己写的东西被删除,请前往个人沙盒

所有编辑请在此处以下进行

生存难度:

天堂

•美丽

•宁静

•完美

让我们说中文 level 1145141919810520131492233720368547758082147483648 模板:DPL manual

模板:Tocright


With controlling output format, it is possible to:

  • Setting basic modes of output formatting.
  • Set advanced modes of output formatting (complete control over output).
  • Generate simple/quick tabular output.
  • Generate advanced tabular output (or format though special surrogate formatting templates).
  • Apply formatting to and around lists with headings (and their contents).
  • Arranging article lists in columns and rows (模板:Red).
  • Control (or rewrite) the way article names are displayed.


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

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.
  2. There is a mode called userformat which puts complete control into your hands.
    • You will understand their meaning directly from reading.


Setting the basic output mode

mode

模板:DPL parameter


Syntax:

模板:Syntax where modename can be one of:

  • unordered – outputs an unordered list – HTML tag 模板:Tt – (default).
  • ordered – outputs an ordered list – HTML tag 模板:Tt.
  • none – outputs a list using newlines and HTML tags 模板:Tt to separate each item.
  • inline – outputs a list using symbols defined by the 模板:DPL parameter to separate items.
  • category – outputs resulting articles in a way category pages are shown (模板:DPL= must be used with one of the values: 模板:Tt; 模板:Tt; 模板:Tt; or 模板:Tt).
  • userformat – leaves output control completely to the user.
    See parameters 模板:DPL and 模板:DPL; in this mode, DPL3 offers built-in variables which must be referenced in the output format description provided by the user. 模板:DPL=userformat is essential to have complete control over the output.


For advanced use of DPL3, it is important to understand 模板:DPL=userformat. Note that this mode is automatically implied when 模板:DPL or 模板:DPL 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 模板:Tt list (numbered), an 模板:Tt list (bulleted), or the 模板:Tt list style (no list item markers). 模板:ViewTest


In an <ol>...</ol> list: In a <ul>...</ul> list: In a <br/> list:
{{#dpl:
|category      = Fruit examples
|titlematch    = %a%
|nottitlematch = %pl%¦%go%
|mode          = ordered
|count           = 3
}}
{{#dpl:
|category      = Fruit examples
|titlematch    = %a%
|nottitlematch = %pl%¦%go%
|mode          = unordered
|count           = 3
}}
{{#dpl:
|category      = Fruit examples
|titlematch    = %a%
|nottitlematch = %pl%¦%go%
|mode          = none
|count           = 3
}}


mode 'category'


Example:

Examples/Parameter: mode (example 2) 模板:ViewTest


Note: You must use 模板:DPL 模板:=  with one of: title / titlewithoutnamespace / category,title / user,title with this option.


mode 'inline'

inlinetext

模板:DPL parameter


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


The default formatting is 模板:&-模板:& which results in  -  except when 模板:DPL=userformat where 模板:DPL is empty by default.


Notes:

  • To get normal "breaking spaces" (and not the NON-breaking spaces) use 模板:&-模板:&.
  • Extra white spaces are stripped by DPL3 from the beginning and end of wikitext. To show one or multiple spaces, use one or multiple &nbsp;, or use nowiki tags <nowiki> - </nowiki> which has the same effect as &nbsp-&nbsp.
  • Bullets can be displayed with either 模板:& or 模板:Tl.


Example:

Examples/Parameter: mode (example 3) 模板:ViewTest

Result:
Examples/Parameter: mode (example 3) 模板:Anc



mode 'userformat'


模板:Note


While the standard output formats are meant to be used for fast generation of simple page lists, the 模板:DPL 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 模板:Tt and 模板:Tt which use templates 模板:Tt and 模板:Tt with varying arguments; while 模板:Tt is being used once within each document, 模板:Tt 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 模板:DPL. So 模板:Tt might contain a reference like %PAGE% to output the page name. See 模板:DPL for more details on variable substitution.


Now think of the following page inclusion statement:

  includepage={x}.dpl,{y}.dpl


The output then looks 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 (模板:Tt, 模板:Tt, etc.) contain wiki syntax for table definitions and 模板:Tt 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, an output table may be desired where each of the calls of template 模板:Tt is used to create a separate output row. Using a sortable table, the output could then be easily rearranged.

  +------+---------------------+       +------+---------------------+
  |  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 模板:DPL which can be used to mark one section of the 模板:DPL statement as "dominant" (in our example: "dominantsection=2" as 模板:Tt is the second argument of the 模板:DPL statement). Only one dominant section can be used in a DPL3 statement. Marking a section as "dominant" only makes sense if there are multiple calls of the same template (or multiple page sections/chapters with the same heading) in the documents. Each piece of content in the dominant section generates an individual output row with the values of all other columns being repeated.


format

模板:DPL parameter


Syntax:

模板:Syntax where 模板:Tt, 模板:Tt, 模板:Tt and 模板:Tt are wiki tags used to separate the list items:


Notes:

  • 模板:DPL is an alias for 模板:DPL.
  • The 模板:DPL command is very flexible, but somewhat complicated. To create tabular output, also see the 模板:DPL command.
  • Because wiki syntax depends on newline characters, \n 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 \n or must be used.
  • A numbered list in wiki syntax is defined by a # at the beginning of a line – therefore \n 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 DPL3, an unordered (bulleted) list, can be produced by using a default statement (first example and result). It can also be created using 模板:DPL 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 format statement's 模板:Tt, 模板:Tt, and 模板:Tt arguments are empty, only 模板:Tt is used to manually define a bulleted list followed by the liked page name, which is then applied to each row of output. 模板:ViewTest

default formatted
<dpl>
  titlematch	  = %ntries%
  nottitlematch	  = %f%
  includesubpages = false
</dpl>
<dpl>
  titlematch	  = %ntries%
  nottitlematch	  = %f%
  includesubpages = false
  format	  = ,\n* [[%PAGE%|%TITLE%]],,
</dpl>


Example:

Examples/Parameter: format (example 2) 模板:ViewTest


Result:
Examples/Parameter: format (example 2)

Notes:

  • You can also use HTML syntax for the tags, although this is discouraged.
|format   = <ul type="disc">,<li>[[%PAGE%]],</li>,</ul>


The 模板:DPL parameter can be used to create a table using wiki syntax (note that the parser function syntax {{#dpl:}} invocation method requires the pipe | characters to be replaced by broken pipe ¦. Again, as wiki syntax depends on newline characters, \n or must be used to explicitly insert newline characters into the output.


Example:

Examples/Parameter: format (example 3) 模板:ViewTest


Result:
Examples/Parameter: format (example 3)


Notes:

  • The 模板:Tt position of the format= 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 the Main namespace, such as in the "Category" namespace, if "Category:" is not desired in the page title/link, [[%PAGE%|%TITLE%]] can be used instead.
  • The 模板:DPL parameter, with 模板:DPL and the 模板:DPL/模板:DPL parameter, can also be used to output table syntax.


Image galleries can also be produced using the format syntax.


Example:

Examples/Parameter: format (example 4) 模板:ViewTest


Result:
Examples/Parameter: format (example 4)


模板:Anc


Variables

As we want to be able to control output completely, we reference article names and other possible output by special 模板:DPL: 模板:Anc

Variable Description
%PAGE% Outputs the name of the article (including namespace), corresponds to the Magic Word {{FULLPAGENAME}}.
%TITLE% Outputs the title of the article (without the namespace), corresponds to the Magic Word {{PAGENAME}}.
%NAMESPACE% Outputs the namespace of the article.
%PAGEID% Outputs the internal unique numeric ID of the article page.
%NR% Outputs the current article sequence number (starting from 1).
%IMAGE% Outputs the physical path to an image (based on hash values, e.g., 5/5d/myImage.jpg).
%PAGESEL% Outputs the name of an article which was used within the selection criteria (only applies to 模板:DPL and 模板:DPL).
%IMAGESEL% Outputs the name of an image which was used within the selection criteria (only applies to 模板:DPL).
%SIZE% Outputs the article size (requires 模板:DPL=true).
%SIZEFS% Outputs a font size number which is based on the article size (logarithm of square root of counter).
%DATE% Outputs the date selected, e.g., ordermethod=模板:Tt; requires 模板:DPL=true or similar; the formatting of the date can be influenced using 模板:DPL=.
%EXTERNALLINK% Outputs the external hyperlink found as a consequence of the 模板:DPL statement.
Relating to categories
%CATLIST% Outputs a pipe-separated list of links to all categories to which the article belongs (requires 模板:DPL=true).
%CATBULLETS% Outputs a bullet point list of links to all categories to which the article belongs (requires 模板:DPL=true).
%CATNAMES% Outputs a comma-separated list of all categories to which the article belongs (requires 模板:DPL=true).
Relating to Revisions and Contributors
%REVISION% Outputs the name of the article revision; only accessible if the DPL query selects articles based on revision dates.
%USER% Outputs the user who changed the article last; requires 模板:DPL=true or 模板:DPL=true.
%CONTRIBUTOR% Outputs the user who made a contribution; requires 模板:DPL=true.
%CONTRIBUTION% Outputs the number of bytes changed; requires 模板:DPL=true.
%CONTRIB% Outputs asterisk * bar to indicate the amount of change; requires 模板:DPL=true.

Note: The above variables are replaced by the corresponding values if they occur within Start or End or within the corresponding tags of the 模板:DPL= parameter.

Variable Description
Symbolic variables for use in 模板:DPL and/or 模板:DPL
%PAGES% Outputs the number of articles in the result set. If the query result is limited (by system settings or by the 模板:DPL parameter) %PAGES% only shows the upper limit.
%TOTALPAGES% Outputs the number of articles in the result set, regardless of count limits, which may consume extra resources; it is only calculated if used.
%VERSION% Displays the current DPL3 version (see also Special:Version).
%DPLTIME% Outputs the amount of time that the DPL3 call itself took (in seconds + milliseconds).
  • This useful to find out if or which DPL3 call, on a page, is taking a long time (if long loading times are noticed).
  • Example: 2 (2009/06/13 09:27:43) would mean the DPL3 call accounts for 2 seconds of the total load time, and that the call started at bracketed time.
Variables for 模板:DPL

%FIRSTNAMESPACE%
%FIRSTTITLE%
%LASTNAMESPACE%
%LASTTITLE%

Variables used for page scrolling, that produce the output described in their names. These variables
correspond to 模板:DPL and 模板:DPL of the first / last article in the result set, respectively.
%SCROLLDIR% Outputs the value set by the URL parameter 模板:Tt (up or down);
it is passed to the scroll helper template, which uses it to produce its links for scrolling.
Removed parameters
%COUNT% The usage counter (requires 模板:DPL=true). The built-in feature for this was 模板:Red in MediaWiki 1.25.[1]

模板:Note

%COUNTFS% A font size number which is based on the usage counter (currently this is the logarithm of the usage counter). The built-in feature for this was 模板:Red in MediaWiki 1.25.[1]

模板:Note

%COUNTFS2% Similar to %COUNTFS%, but based on the logarithm of the square root of the usage counter. The built-in feature for this was 模板:Red in MediaWiki 1.25.[1]

模板:Note


listseparators

模板:DPL parameter


secseparators

模板:DPL parameter

Syntax:

模板:Syntax

or

模板:Syntax


In the first syntax variant, specify pairs of tags which correspond to the 模板:DPL statement. 模板:Tt and 模板:Tt are HTML strings or wiki tags which are put around each transcluded section (see 模板:Syntax).

In the second syntax variant, specify just one element which is then used as 模板:Tt for all sections; in this case the second tag (模板:Tt) will be empty for all transcluded sections.

Symbolic replacements of %PAGE% etc. take place as described in 模板:DPL. In addition, the variable %SECTION% can be used to refer to the section found (works only for page section/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 occurrences are transcluded as a block, and the 模板:DPL tags are only put once around the whole block (but see 模板:DPL).


Example:

Examples/Parameter: secseparators (example 1) 模板:ViewTest


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


Example:

Examples/Parameter: secseparators (example 2) 模板:ViewTest


multisecseparators

模板:DPL parameter


Syntax:

模板:Syntax

The tags correspond to the transcluded section (see 模板:Syntax).

Symbolic replacements of %PAGE% etc. take place as described in 模板:DPL. In addition, the variable %SECTION% can be used to refer to the section found (works only for chapter headings). It gives the precise name of each heading, even if a regular expression (double ##) was used in the include statement.

If an article uses the same template more than once, all references are provided with 模板:Tt as a separator.


Example:

Examples/Parameter: multisecseparators (example 1) 模板:ViewTest


Result:

Examples/Parameter: multisecseparators (example 1)


Values cannot be formatted within 模板:DPL, as formatting can only occur in formatting statements (this can be done in 模板:DPL or 模板:DPL, and 模板:DPL). Variables can be omitted from the 模板:DPL, 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:

Examples/Parameter: multisecseparators (example 2) 模板:ViewTest


Example:

Examples/Parameter: multisecseparators (example 3) 模板:ViewTest Formatting handled by a surrogate (also known as phantom) template (e.g., Template:DPL parameter.surrogateexample‎‎) applies to both 模板:DPL and 模板:DPL.

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 "View result" is clicked). In the surrogate and in the result, it can be seen that 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 模板:DPL and 模板:DPL parameters for more information.


dominantsection

模板:DPL parameter


Syntax:

模板:Syntax between 1 and the number of arguments in the 模板:DPL= statement


If there is only 0 or 1 piece of content for the dominant section, no difference from normal DPL3 behavior is observed.

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


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


Generating tabular output

table

模板:DPL parameter


Syntax:

模板:Syntax


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


Parameters automatically set by table are:

  • 模板:DPL=userformat.
  • 模板:DPL is configured to produce table definition wiki syntax.
  • 模板:DPL is configured to produce table row wiki syntax.
    • The first column always contains a hyperlink to the article of the query result (unless suppressed using '-' in the link header as described below).
  • 模板:DPL is configured to produce another table row wiki syntax, for multiple occurrences of the first 模板:DPL argument.
    • For all other arguments:
      • Template parameters – A line break is used (because a table where each template invocation becomes a row in the table may be desired).
      • Page section contents– A line break is used (Note: Formerly a horizontal separation line was noted, but this changed some time ago).


It does not make sense to use one of the other parameters mentioned, if 模板:DPL is used in a DPL3 statement because their values are overwritten without notice.

  • There is one exception to this rule, it can make sense to specify the third argument for 模板:DPL combined with 模板:DPL; therefore, this parameter is NOT overwritten by the 模板:DPL command. The third argument can be used to output metadata like 模板:DPL, 模板:DPL etc., as columns in an output table. To do so, the third parameter must contain wiki syntax for output columns like this:
include = {some template}:param1,#some-section-heading
table   =,,tplparam,#sectionheading,#hits
format  =,,\n%COUNT%

This provides a table which contains template parameters, article section/chapter contents, and the usage counter as a third column. Metadata can only be placed AFTER normal contents, the third argument of the table statement adds %COUNT% to add that value after that column's normal content.


Important:

  • An 模板:DPL statement is required to use table.
  • Each argument of the 模板:DPL statement produces one or more values for the output described by the 模板:DPL statement.
  • For reasons of readability and because the include and table statements correspond, the include statement should directly precede the table statement.


table expects a comma-separated list of arguments:


table = class="wikitable sortable",First column header,Second column header,...

  • The first argument assigns general properties for the table.
    • It is recommended to make a CSS reference here, using something like class="wikitable sortable", or class="mytable" if 模板:Tt is defined in the Mediawiki:Common.css document.
    • class="wikitable" is the default value if left empty.
  • The second argument is the headline for the first column.
    • A - hyphen in the second argument suppresses the automatically generated first column of output.
      • You can manually create a hyperlink to the article in any other column instead, using [[{{{%PAGE%}}}|{{{%TITLE%}}}]], in a 模板:DPL 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 specify the column headings, which correspond to the arguments of the 模板:DPL parameter. If a surrogate template is called (like 模板:Tt) in the include statement, as many headlines as the surrogate template produces columns needs to be provided.


Example:

Examples/Parameter: table (example 1) 模板:ViewTest

Result:
Examples/Parameter: table (example 1)

Example:

Examples/Parameter: table (example 2) 模板:ViewTest

Result:
Examples/Parameter: table (example 2)

When using surrogate templates (i.e., templates that format a single row of output, called during DPL3 execution, and then applied by DPL3 to subsequent rows), they must be written to produce output according to wiki table syntax. The table 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: {{{1|}}}
   |
   some output for the next column: {{{2|}}}
   |
   some output for the next column: {{{3|}}}

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

A typical DPL3 statement using the 模板:DPL parameter would contain:

include =                            #Section X,   {T1}:param1   ,#Section 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 模板:DPL and 模板:DPL. You can see the first two arguments define the table characteristics and then the first column (for the hyperlink to the article) and headline. Then follow headlines for each argument of 模板:DPL. Note that there are two headlines which correspond to the last argument of the 模板:DPL statement (assuming that 模板:Tt outputs two columns). 模板:Tt itself might have more or less than 2 arguments – it only matters how many columns are output by 模板:Tt).


Example:

Examples/Parameter: table (example 3) 模板:ViewTest

Result:
Examples/Parameter: table (example 3)

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


tablerow

模板:DPL parameter


Syntax:

模板:Syntax where 模板:Tt uses the symbol %% to precisely position content included by an 模板:DPL statement, within wikitext formatting code.


When it comes to simple tables using tablerow, an 模板:DPL statement first tells DPL3 what content to include in each column of a table, the 模板:DPL 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 模板:DPL is to precisely position the column values %% of the corresponding include, 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 defining the formatting, it's possible to start with cell styles/attributes like style="background:grey;"¦ (followed by the value %%) or skipping such styles and just adding the value %%. All columns must be specified, meaning as many entries in the 模板:DPL statement must exist as there are columns in the table. Skipping a column would suppress output for that column completely.


Example:

Examples/Parameter: tablerow (example 1) 模板:ViewTest

Result:
Examples/Parameter: tablerow (example 1)


Notes:

  • You can add a leading \n 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 tablerow use (and other methods of generating tabular data).


tablesortcol

模板:DPL parameter


Syntax:

模板: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;
  • tablesortcol = 0 means do not sort; this is the default.
  • Negative numbers are used to sort in descending order; e.g., 模板:Tt would sort according to the third column in descending order.
  • Note that the rest of the row after the selected column are also 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 column formatting commands were used. For the same reason, numeric contents cannot be expected to sort numerically – sorting is always alphabetical.
  • You can, of course, use something like class="sortable" or class="wikitable sortable" together with 模板:DPL. The difference is that:
    • Interactive sorting only works after the article has been initially displayed.
    • Interactive sorting tries to guess the content type of column and sorts according to that (date, number, string)
  • If 模板:DPL is not used, the output order of table rows depends on the sort order by which the articles were analyzed. That order depends on other DPL3 commands like 模板:DPL. The default is "alphabetically by title". So, without 模板:DPL table rows appear in alphabetical sequence of the article names where they come from. With 模板:DPL these can be ordered by the column contents itself.

Example:

Examples/Parameter: tablesortcol (example 1) 模板:ViewTest

Result:
Examples/Parameter: tablesortcol (example 1)

Heading mode

headingmode

模板:DPL parameter


Syntax:

模板:Syntax where modename can be one of:


Important notes:

  • If a single category is used to select articles for the result set, and those articles belong to more than one category, all categories they belong to are displayed as headings and the articles themselves will repeat under each category they belong to, unless extra categories are deliberately filtered off with other page selection parameters. The distinct parameter would have no effect on this behavior because the articles are already distinct to each category (and distinct=true is already the default, setting it would not change the result).
  • headingmode can be used with multi-column output, but the length of the columns may vary more expected.


Example:

Examples/Parameter: headingmode (example 1) 模板:ViewTest

Result:
Examples/Parameter: headingmode (example 1)


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


Example:

Examples/Parameter: headingmode (example 2) 模板:ViewTest

Result:
Examples/Parameter: headingmode (example 2)

hlistattr

模板:DPL parameter


Syntax:

模板:Syntax


Example:

Examples/Parameter: hlistattr (example 1) 模板:ViewTest


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

<dl id="dl-example" class="dpl-orange-background">
  <dt>Category_1</dt>
  <dd>
    <ol>
      <li>Page 1</li>
    </ol>
  </dd>
  <dt>Category_1</dt>
  <dd>
    <ol>
      <li>Page 2</li>
    </ol>
  </dd>
</dl>


Result:
Examples/Parameter: hlistattr (example 1)


Note: To format subsequent elements in the same result set, see also (in the corresponding order since the examples build on one another) 模板:DPL, 模板:DPL, 模板:DPL.


hitemattr

模板:DPL parameter


Syntax:

模板:Syntax


Example:

Examples/Parameter: hitemattr (example 1) 模板:ViewTest


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

<dl id="dl-example" class="dpl-orange-background">
  <dt>Category_1</dt>
  <dd id="list-item-heading" class="list-item-heading">
    <ol>
      <li>Page_1</li>
    </ol>
  </dd>
  <dt>Category_2</dt>
  <dd id="list-item-heading" class="list-item-heading">
    <ol>
      <li>Page_2</li>
    </ol>
  </dd>
</dl>

Result:
Examples/Parameter: hitemattr (example 1)

Example:

Examples/Parameter: hitemattr (example 2) 模板:ViewTest

Result:
Examples/Parameter: hitemattr (example 2)


Note: To format subsequent elements in the same result set, see also (in the corresponding order since the examples build on one another) 模板:DPL, 模板:DPL.


listattr

模板:DPL parameter


Syntax:

模板:Syntax


Example:

Examples/Parameter: listattr (example 1) 模板:ViewTest


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

<dl id="dl-example" class="dpl-orange-background">
  <dt>Category_1</dt>
  <dd id="list-item-heading-attrubite" class="list-item-heading-attrubite">
    <ol id="ol-example" class="dpl-blue-background">
      <li>Page_1</li>
    </ol>
  </dd>
  <dt>Category_2</dt>
  <dd id="list-item-heading-attrubite" class="list-item-heading-attrubite">
    <ol id="ol-example" class="dpl-blue-background">
      <li>Page_1</li>
      <li>Page_2</li>
    </ol>
  </dd>
</dl>


Result:
Examples/Parameter: listattr (example 1)


Note: To format subsequent elements in the same result set, see also (in the corresponding order since the examples build on one another) 模板:DPL.


itemattr

模板:DPL parameter


Syntax:

模板:Syntax


Example:

Examples/Parameter: itemattr (example 1) 模板:ViewTest


If there are multiple pages output for each category, the HTML structure output is:

<dl id="dl-example" class="dpl-orange-background">
  <dt>Category_1</dt>
  <dd id="list-item-heading-attrubite" class="list-item-heading-attrubite">
    <ol id="ol-example" class="dpl-blue-background">
      <li id="li-example" class="li-example">Page_1</li>
    </ol>
  </dd>
  <dt>Category_2</dt>
  <dd id="list-item-heading-attrubite" class="list-item-heading-attrubite">
    <ol id="ol-example" class="dpl-blue-background">
      <li id="li-example" class="li-example">Page_1</li>
      <li id="li-example" class="li-example">Page_2</li>
    </ol>
  </dd>
</dl>


Result:
Examples/Parameter: itemattr (example 1)

headingcount

模板:DPL parameter


Syntax:

模板:Syntax


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


userdateformat

模板:DPL parameter


Syntax:

模板:Syntax where 模板:Tt sets the date format.

The 模板:Tt 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 [1]. The userdateformat applies to all date/time fields, see the parameters: 模板:DPL, 模板:DPL,模板:DPL.


Example:

userdateformat=Y-m-d (D)

Default:

By default, DPL3 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, DPL3 translates 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 is used.

So, either time based on the user's local time (browser based), or based on the timezone in which the wiki server is running is seen.

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


Control the way article names are displayed

shownamespace

模板:DPL parameter


Syntax:

模板:Syntax


Example:

Examples/Parameter: shownamespace (example 1) 模板:ViewTest

Result:
Examples/Parameter: shownamespace (example 1)


Note: In 模板:DPL=userformat there is a different way to decide whether output the title with or without namespace is desired; two built-in variables are provided which contain the page name including the namespace (模板:DPL) and the base title name (模板:DPL). Setting [[%PAGE%|%TITLE%]] links to the full page with namespace, but displays the link text without namespace.


escapelinks

模板:DPL parameter


Syntax:

模板:Syntax

Example:

Examples/Parameter: imagecontainer (example 1) 模板:ViewTest

Result:
Examples/Parameter: imagecontainer (example 1)


Notes:

  • You can use this parameter to show images, the images are displayed at the largest size as will fit on the page (which may be larger than is appropriate).
  • Another way to do this is to:
  • Use a format statement, such as: |format = ,[[File:%TITLE%|40px]] as in the second example here.
  • Use gallery syntax within a format statement, as in the example here.


titlemaxlength

模板:DPL parameter


Syntax:

模板:Syntax


Example:

Examples/Parameter: titlemaxlength (example 1) 模板:ViewTest

Result:
Examples/Parameter: titlemaxlength (example 1)


replaceintitle

模板:DPL parameter


Syntax:

模板: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, it must be written as:

replaceintitle=/demo/,

Example:

Examples/Parameter: replaceintitle (example 1) 模板:ViewTest

Result:
Examples/Parameter: replaceintitle (example 1)


Notes:

  • Standard regexp rules apply.
  • The regexp must start with a non-alphanumeric character – but not necessarily with a backslash! It is a good habit to use / if this character is not needed within the regexp itself.

模板:Regexpinfo


Arranging article lists in columns and rows

columns

模板:DPL parameter


Syntax:

模板:Syntax where 模板:Tt is the number of desired columns.


模板:Note


This (if it worked) displays articles in Category:Fruit examples‏‎, a count of three, arranged in 3 columns (模板:DPL is used to make the table width 100%).

{{#dpl:
|category        = Fruit examples
|includesubpages = false
|columns         = 3
|rowcolformat    = width=100%
|count           = 3
}}


Workaround example:

Examples/Parameter: columns (example 1) 模板:ViewTest


Workaround result:
Examples/Parameter: columns (example 1)


Note: In 模板:DPL=userformat the outer tags from listseparators are repeated for each column. This means that such a statement could create tables within columns, with something like:

  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

模板:DPL parameter


Syntax:

模板:Syntax where 模板:Tt is the number of desired rows.


In 模板:DPL=userformat, the outer tags from 模板:DPL are repeated for each column. Thus, long lists can be created where the table heading is repeated from time to time.


This would (if it worked) list the largest articles in Category:Fruit examples‏‎, 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.

模板:Tempnote


Example:

{{#dpl:
|category        = Fruit examples‏‎
|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
}}


Result:


rowsize

模板:DPL parameter


Syntax:

模板:Syntax where 模板:Tt is the desired row size.


In 模板:DPL=userformat the outer tags from 模板:DPL are repeated after each group of 模板:DPL output lines. Thus, long lists can be created where the table heading is repeated in regular intervals.


The (if it worked) lists all articles in Category:Fruit examples‏‎. After each group of 3 entries (article names) the table heading is 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.


Example:
模板:Tempnote

{{#dpl:
|category        = Fruit examples‏‎
|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¦}
|rowsize         = 3
|count           = 6
}}


rowcolformat

模板:DPL parameter


Syntax:

模板:Syntax where 模板:Tt are the desired (allowed) HTML tags to set.


Example:
模板:Tempnote This (if it worked) lists articles in Category:Fruit examples, displayed in 3 columns, with more space around the columns.

{{#dpl:
|category        = Fruit examples
|columns         = 3
|rowcolformat    = cellspacing=20
|count           = 6
}}


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


Example:

{{#dpl:
|category        = Fruit examples
|includesubpages = false
|columns         = 3
|rowcolformat    = class="dpl3columns"
|count           = 6
}}


In MediaWiki:Common.css article, something like the following might be written:

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


References

  1. 1.0 1.1 1.2 The built-in features of hit counters were completely removed in MediaWiki 1.25, following a request for comment. See Hit counters removed, though this functionality can be restored by adding the HitCounters extension.