General usage and invocation syntax: Difference between revisions

From DynamicPageList3 Manual
Content added Content deleted
 
imported>FrozenPlum
m (Update template link)
 
(38 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{Type Manual|section=General Usage and Invocation Syntax}}
{{DPL manual|section=General usage and invocation syntax}}
{{tocright}}


'''DynamicPageList3 (DPL3)''' can be used as a '''parser extension''' (<small><code><nowiki><dpl> .... </dpl></nowiki></code></small>) or as a '''parser function''' (<small><code><nowiki>{{#dpl: .... }}</nowiki></code></small>). There is no general rule which one is better. If in doubt, you may want to use the '''parser function syntax''', as it '''is more powerful'''.


DPL2 can be used as a '''parser extension''' (<small><code><nowiki><DPL> .... </DPL></nowiki></code></small>) or as a '''parser function''' (<small><code><nowiki>{{#dpl: .... }}</nowiki></code></small>). There is no general rule which one is better. If in doubt, you may want to use the parser function syntax as it is more powerful.


;Sample output
;Sample output
Both of the following examples, which illustrate the difference between using DPL as a parser extension and using it as a parser function, will produce a list of all articles which belong to ''cat1'' or ''cat2'' and which contain a reference to ''myPage''. The output of these DPL calls would be something like:
Both of the following examples, which illustrate the difference between using DPL3 as a parser extension and using it as a parser function, will produce a list of all articles which belong to ''cat1'' or ''cat2'' and which contain a reference to ''myPage''. The output of these DPL3 calls would be something like:


:* [[Page 1]]
* [[Apple]]
:* [[Page 2]]
* [[Grape]]
:* [[Another Page]]
* [[Orange]]


==Syntax used in this manual==

Most examples in this manual typically use the parser function-based syntax, <code><nowiki>{{#dpl:}}</nowiki></code> given it is the more flexible syntax. Examples are wrapped in <code><nowiki><pre></pre></nowiki></code> tags, so the plain wikitext used to create a result can be seen without rendering the result itself.

Most of the manual deals with the explanation of individual parameters. This is independent of the choice between the two variants described above. So, if you read something like
* parameter = value
you should have in mind that you must either place DPL3 tags around (using a separate line for each parameter) or use the parser function syntax and separate parameters by pipe characters.


==DPL3 Invocation syntax==
===Parser extension (tag) method===
The following example would probably be used directly on an article page, but could also be included as part of a template. Parser extensions define a specific tag (in this case <code><nowiki><dpl></nowiki></code>) and a corresponding end tag (<code><nowiki></dpl></nowiki></code>). '''The text between these tags is handed over to the extension module ''just as it is''.'''


=== Parser extension method ===
The following example would probably be used directly on an article page, but could also be included as part of a template. Parser extensions define a specific tag (in this case <tt><nowiki><DPL></nowiki></tt>) and a corresponding end tag (<tt><nowiki></DPL></nowiki></tt>). '''The text between these tags is handed over to the extension module ''just as it is''.'''


;Example syntax
;Example syntax
<pre>
<blockquote><pre><nowiki>
<DPL>
<dpl>
category = cat1|cat2
category = cat1|cat2
# only pages which contain a link to myPage
# only pages which contain a link to myPage
linksto = myPage
linksto = myPage
</DPL>
</dpl>
</nowiki></pre></blockquote>
</pre>



;Parsing procedure
;Parsing procedure
Wiki markup expansion ''does not take place'' before the commands are handed over to the extension module.
Wiki markup expansion ''does not take place'' before the commands are handed over to the extension module.
* This may be useful if you want to pass wiki syntax elements to DPL2 as arguments (see the <tt>[[format]]</tt> option, for example).
* This may be useful if you want to pass wiki syntax elements to DPL3 as arguments (see the {{DPL|format}} option, for example).
* [[mw:Magic words|Magic words]] like <tt><nowiki>{{PAGENAME}}</nowiki></tt> or <tt><nowiki>{{CURRENTDAY}}</nowiki></tt> '''cannot''' be used.
* [[mw:Magic words|Magic words]] like <code><nowiki>{{PAGENAME}}</nowiki></code> or <code><nowiki>{{CURRENTDAY}}</nowiki></code> '''cannot''' be used.
* Template calls like <tt><nowiki>{{{some template}}}</nowiki></tt>, cannot be used as parameters.
* Template calls, like <code><nowiki>{{some template}}</nowiki></code>, cannot be used as parameters.
* Parser function calls like <tt><nowiki>{{#if:...|...|...}}</nowiki></tt> cannot be used within arguments.
* Parser function calls like <code><nowiki>{{#if:...|...|...}}</nowiki></code> cannot be used within arguments.
* To pass wiki syntax elements to DPL as parameters it is sometimes necessary to enforce a line break. The reason is that wiki syntax depends on line breaks. Instead, use <tt>\n</tt> or <tt>¶</tt> for that purpose.
* To pass wiki syntax elements to DPL3 as parameters, it is sometimes necessary to enforce a line break. The reason is that wiki syntax depends on line breaks. Instead, use <code>\n</code> or <code>¶</code> for that purpose.



;Syntax features
;Syntax features
* Every parameter assignment (<tt>=command</tt>) has to be on a separate line.
* Every parameter assignment (<code>=command</code>) has to be on a separate line.
* Lines starting with a # will be ignored (comment).
* Lines starting with a # will be ignored (comment).
* Generally the syntax looks fairly simple and intuitive as it doesn't contain special characters (except for the two embracing tags).
* Generally the syntax looks fairly simple and intuitive as it doesn't contain special characters (except for the two embracing tags).
* Tag case doesn't matter, so it can also be written <tt><nowiki><dpl></nowiki></tt>.
* Tag case doesn't matter, so it can also be written <code><nowiki><dpl></nowiki></code>.
* In many cases there is no need to have macro expansion within the parameter list. Note that in the example above, the pipe character (which is used to define a logical OR between the two categories) can be written as it is. The name of the page (''myPage''), however, must be a hardcoded constant.
* Often, there is no need to have macro expansion within the parameter list.
* In the example above, the pipe character (which is used to define a logical OR between the two categories) can be written as it is. The name of the page (''myPage''), however, must be a hard-coded constant.


=== Parser function method ===
This example would be used inside a template, and uses the variable <tt><nowiki>{{{1}}}</nowiki></tt> passed to the template. Parser functions look like templates which start with a hash character (#). They are more closely integrated with the wiki system. They are more powerful but their syntax looks a bit more complicated. '''The text between these tags is pre-parsed to expand wiki mark-up ''before'' being handed over to the extension module.'''


===Parser function method===
;Example syntax
This example would be used inside a template, and uses the variable <code><nowiki>{{{1}}}</nowiki></code> passed to the template, which would be set to ''myPage'' here. Parser functions look like templates which start with a hash character (#). They are more closely integrated with the wiki system. They are more powerful, but their syntax looks a bit more complicated. '''The text between these tags is pre-parsed to expand wiki mark-up ''before'' being handed over to the extension module.'''
<blockquote><pre><nowiki>


'''Example syntax:'''<br>
<pre>
{{#dpl: category = cat1{{!}}cat2 | linksto = {{{1}}} }}
{{#dpl: category = cat1{{!}}cat2 | linksto = {{{1}}} }}
</nowiki></pre></blockquote>
</pre>
or
or
<pre>
<blockquote><pre><nowiki>
{{#dpl:
{{#dpl:
|category = cat1¦cat2
|category = cat1¦cat2
|linksto = {{{1}}}
|linksto = {{{1}}}
}}
}}
</nowiki></pre></blockquote>
</pre>


'''Parsing procedure'''<br>


;Parsing procedure
Wiki markup expansions (not the final conversion to HTML) take place before the commands are handed over to the extension module.
Wiki markup expansions (not the final conversion to HTML) take place before the commands are handed over to the extension module.
* Magic words like <tt><nowiki>{{PAGENAME}}</nowiki></tt> or <tt><nowiki>{{CURRENTDAY}}</nowiki></tt> '''can''' be used.
* Magic words like <code><nowiki>{{PAGENAME}}</nowiki></code> or <code><nowiki>{{CURRENTDAY}}</nowiki></code> '''can''' be used.
* Template calls like <tt><nowiki>{{{some template}}}</nowiki></tt>, can be used as parameters.
* Template calls, like <code><nowiki>{{some template}}</nowiki></code>, can be used as parameters.
* Parser function calls like <tt><nowiki>{{#if:...|...|...}}</nowiki></tt> can be used within arguments.
* Parser function calls like <code><nowiki>{{#if:...|...|...}}</nowiki></code> can be used within arguments, though they must be formatted differently <code><nowiki>²{#if:...¦...¦...}²</nowiki></code>



;Syntax features
'''Syntax features'''<br>
* To use wiki characters as arguments, escape them.<!--need link to what this means-->

** It is possible to define a special template like <code><nowiki>{{!}}</nowiki></code> which contains a single | symbol as its contents.
* To use wiki characters as arguments, they must be escaped.
** With DPL it is also possible to use the symbol ¦ instead of |; this is very intuitive and maybe it could be adopted by MediaWiki in general...but be <u>careful</u>: it must be inserted by copy-and-paste from here (or from a HTML symbol or extended ASCII table like Windows' ''Character Map'') as normally a keyboard will not have it available (even worse: on some keyboards the standard pipe character is printed in a way that it looks more like the "broken pipe").
** It is possible to use the [[mw:Help:Magic_words#Other|Magic Word]] <code><nowiki>{{!}}</nowiki></code> which 'hides' the pipe from the MediaWiki parser, ensuring that it is [[mw:Help:Extension:ParserFunctions#Escaping pipe characters in tables|not considered until after]] other items have been expanded, though if multiple need to be used this can make your statements harder to read.
** With DPL3 it is also possible to use the symbol <code>¦</code> instead of <code>|</code>; this is very intuitive, and maybe it could be adopted by MediaWiki in general...but be <u>careful</u>: it must be inserted by copy-and-paste from here (or from an HTML symbol or extended ASCII table like Windows' ''Character Map'') as normally a keyboard will not have it available (even worse: on some keyboards the standard pipe character is printed in a way that it looks more like the "broken pipe").
* The text can (but needs not) be written in one line of text, parameters are separated by pipe characters.
* The text can (but needs not) be written in one line of text, parameters are separated by pipe characters.
* What was said before regarding explicit line breaks also holds true for parser function syntax, i.e. the special symbols <tt>\n</tt> or <tt>¶</tt> must be used to insert an explicit linefeed character into the wiki output stream if wiki symbols are used which must stand at the beginning of a line.
* What was said before regarding explicit line breaks also holds true for parser function syntax, i.e., the special symbols <code>\n</code> or <code>¶</code> must be used to insert an explicit linefeed character into the wiki output stream if wiki symbols are used which must stand at the beginning of a line.


Note: The pipe character, which is used to define a logical OR for the two categories, must be represented as a call of a special template (which would typically be called "Template:!") which has a single pipe character as its contents. The same kind of trick is also found outside DPL in other templates. The second example shows that the <tt>¦</tt> character acts as an alternative to this somewhat awkward notation.


'''Notes:'''
The second example is not literally equivalent to the first one as there is an additional pipe character before the first parameter. Technically, this creates an additional empty parameter, but as empty parameters are silently ignored by DPL it makes no difference.


* The pipe character, which is used to define a logical OR for the two categories, must be represented as a [[mw:Help:Magic words#Other|Magic Word]] <code><nowiki>{{!}}</nowiki></code> which 'hides' the pipe from the MediaWiki parser, ensuring that it is not considered until after other items have been expanded. The second example shows that the <code>¦</code> character acts as an alternative to this somewhat awkward notation.
==== #dplchapter ====
* The second example is not literally equivalent to the first one, as there is an additional pipe character before the first parameter. Technically, this creates an additional empty parameter, but as empty parameters are silently ignored by DPL3 it makes no difference.
Besides '''#dpl''' there is another parser function which you can use in your wiki text. It is called '''[[#dplchapter]]''' and extracts the body of a chapter from some arbitrary wiki text which it receives as a parameter.


=== Characters with special meaning ===


==Special note on ''Self References''==
Sometimes it is necessary to use a character as "plain data" at a place where it normally has a syntactical meaning. Mediawiki is not very clean at character escaping in general. So we had to define our own way in the jungle of "character escaping":


In principle, a DPL3 query could be written in a way that the page containing the query (or the page including a template which contains the query) would be part of the result set. Experience in the past has shown that in some cases this leads to unwanted effects. For instance, the page containing the query from a MediaWiki perspective contains links to all pages it lists. If your DPL3 statement contains a "uses" clause, you will be astonished to find your own page in all results. The same happens with categories... In addition, there were technical problems with self referencing result sets (parser loop references, which seemed very hard to solve). So, it was decided to skip a self reference in the result set by default.
{| class=wikitable


{{note|'''Important:''' DPL3 does not normally return its own page (a self link/reference) in the result set. To include a page that references itself in the result, you must use <code>{{DPL|skipthispage}}</code>|error}}


You can suppress back references to a page containing a DPL3 query by using <code>{{DPL|reset}}</code> and/or <code>{{DPL|eliminate}}</code>.


==Characters with special meaning==

Occasionally, it is necessary to use a character as "plain data" at a place where it normally has a syntactical meaning. MediaWiki is not very clean at character escaping in general. So, we had to define our own way in the jungle of "character escaping":

{| class="wikitable"
|-
|-
! DPL escape character !! Mediawiki character!! Typical use
! DPL3 escape character !! MediaWiki character!! Typical use
|-
|-
| align=center | <code>'''»'''</code> || align=center | &gt; || rowspan=2 | Call another MediaWiki extension into a parameter of a DPL call
| align=center | <code>'''»'''</code> || align=center | &gt; || rowspan=2 | Call another MediaWiki extension into a parameter of a DPL3 call, or create a gallery <code><nowiki><gallery></gallery></nowiki></code> using DPL3's ''parser function'' syntax.
|-
|-
| align=center | <code>'''«'''</code> || align=center | &lt;
| align=center | <code>'''«'''</code> || align=center | &lt;
|-
|-
| align=center | <code>'''²{'''</code> || align=center | <nowiki>{{</nowiki> || rowspan=3 | Call a template within the 'article loop' of DPL. This is especially useful for nesting DPL calls (''DPL recursion'')
| align=center | <code>'''²{'''</code> || align=center | <nowiki>{{</nowiki> || rowspan=3 | Call a [[mw:Help:Templates|template]] or [[mw:Help:Extension:ParserFunctions|parser function]] within the 'article loop' of DPL3's parser function syntax; this is especially useful for nesting DPL3 calls (''DPL recursion'').
|-
|-
| align=center | <code>'''}²'''</code> || align=center | <nowiki>}}</nowiki>
| align=center | <code>'''}²'''</code> || align=center | <nowiki>}}</nowiki>
Line 90: Line 125:
| align=center | <code>'''¦'''</code> || align=center | <nowiki>|</nowiki>
| align=center | <code>'''¦'''</code> || align=center | <nowiki>|</nowiki>
|-
|-
| align=center | <code>'''¶'''</code> || align=center | newline || rowspan=2 | Inserts a line break into DPL's wikitext output, to allow proper parsing of first-character syntax (such as <code>* # : ;</code>)
| align=center | <code>'''¶'''</code> || align=center | newline || rowspan=2 | Inserts a line break into DPL3's wikitext output, to allow proper parsing of first-character syntax (such as <code>{| * # : |} ;</code>)
|-
|-
| align=center | <code>'''\n'''</code> || align=center | newline
| align=center | <code>'''\n'''</code> || align=center | newline
|}
|}


DPL's mechanism of replacing <code>%xx%</code> variables then can be used to modify the arguments of that call '''before''' it will be resolved. Most DPL users will not need this, but for some advanced uses of DPL it is a real help.
DPL3's mechanism of replacing <code>%xx%</code> variables then can be used to modify the arguments of that call '''before''' it will be resolved. Most DPL3 users will not need this, but for some advanced uses of DPL3 it is a real help.


=== Built-in VARIABLES ===


==Built-in variables==
Within a DPL statement you can use some [[variables]] which are implicitly set by DPL.
Example: %TITLE%, %PAGE%


Some [[variables]] can only be used in the header or footer, like e.g. %PAGES%, %TOTALPAGES%
Within a DPL3 statement, you can use some symbols (called ''variables'' in this manual) which are implicitly set by DPL3. Some variables can only be used in the header or footer.
{{#lst:Controlling output format|formatvariables}}
{| class="wikitable mw-collapsible" style="max-width:1200px;"
! Variable
! Description
|-
|<code>%SECTION%</code>
|The page name and its included section anchor <code>''Page Name#SectionName''</code>. Corresponds to <code>include=''#SectionName''</code> (when a page section is included by name). It currently appears that <code>%SECTION%</code> can only be used in <code>{{DPL|secseparators}}</code>.
|-
|<code>%PFUNC%</code>
|The name of the parser function, set when <code>{{DPL|include}}</code> is used to look for parser function calls in an article or result set. This variable requires a corresponding <code>include</code> statement and is not very robust, it cannot handle nested parser functions properly. <code>%PFUNC%</code> is only applicable to the template for which the parser function and its parameters are passed (under their normal names or numbers).
|-
|<code>%TAG%</code>
|The name of the parser extension (tag), set when <code>{{DPL|include}}</code> is used to look for parser extension (tag) calls an article or result set. This variable requires a corresponding <code>include</code> statement and is not very robust, it cannot handle nested parser functions properly. <code>%TAG%</code> is only applicable to the template for which the parser extension information is passed.
|-
|<code>%TAGBODY%</code>
|The body content (as-is, including line breaks) of the parser extension (tag), set when <code>{{DPL|include}}</code> is used to look for parser extension calls an article or result set. This variable requires a corresponding <code>include</code> statement and is not very robust, it cannot handle nested parser functions properly. <code>%TAGBODY%</code> is only applicable to the template for which the parser extension information is passed.
|}


=== URL parameters ===


==Scrolling/URL Parameters==
DPL understands a couple of parameters which can be passed via an URL specification. These URL-parameters all start with DPL_:
* DPL_count: influences the [[count]] parameter (in fact it overwrites the value specified within the DPL statement)
* DPL_offset: influences the [[offset]] parameter (in fact it overwrites the value specified within the DPL statement)
* DPL_refresh: if used with a value of 'yes' this will clear the DPL cache
* DPL_fromTitle: restrict the selection to articles with a page title greater or equal to the specified value
* DPL_toTitle: restrict the selection to articles with a page title less or equal to the specified value
* DPL_arg1, DPL_arg2, .. DPL_arg5: these are generic parameters that can be used freely to influence a DPL statement


DPL3 supports efficient scrolling through huge result sets. Basically, the idea of backward scrolling is that the SQL statement produces a DESCENDING order (with titles below the threshold). Internally, DPL3 buffers the SQL result set and reverses its order. So, the user will see a page of entries directly below the threshold, but in ascending order.
The command


The command <code>scroll=''yes''</code> must be given to enable scrolling.
<pre><nowiki> http://mywebsite/mywiki/index.php?title=MyPage&DPL_offset=20 </nowiki></pre>


would display ''MyPage'' and set the offset parameter to a value of ''20''.


===Scroll/URL syntax===
Within the DPL statement you cann access URL parameters via

If scrolling is enabled, DPL3 1.8.0 and later will take some parameters from the URL command line (e.g., like <code>DPL_offset</code>); these parameters can be accessed within DPL3 via a special syntax:
* <code>{%DPL_offset%}</code>.
or
* <code>{%DPL_offset:defaultvalue%}</code>.

Within the DPL3 statement, you can access URL parameters via
{%DPL_xxx%}
{%DPL_xxx%}
If a parameter is not set in the URL, DPL will assume an empty string. Instead you can define a default value by using a colon:
If a parameter is not set in the URL, DPL3 will assume an empty string. Instead, you can define a default value by using a colon:
{%DPL_xxx:yyy%}
{%DPL_xxx:yyy%}
In this case DPL will use 'yyy' if the parameter DPL_xxx is not specified on the URL command line.
In this case, DPL3 will use 'yyy' if the parameter DPL_xxx is not specified on the URL command line.


Note: There is a template called [[Template:Extension DPL scroll]] which uses DPL_offset and DPL_count to provide a generic page scrolling method for huge result sets.


'''Note:''' There is a template called [[Template:DPL3 scroll]] which uses <code>DPL_offset</code> and <code>DPL_count</code> to provide a generic page scrolling method for huge result sets, where there is an expected number of results. See {{DPL|scroll}} for more information.
=== Syntax used in this manual ===


If we give complete examples we will typically use the tag based parser extension syntax in this manual. Except when we want to make use of variable expansion.


===Scroll/URL parameters===
Most of the manual deals with the explanation of individual parameters. This is independent of the choice between the two variants described above. So, if you read something like

* parameter = value
When scrolling is enabled, DPL will interpret the following special parameters in the URL.
you should have in mind that you must either place DPL tags around (using a separate line for each parameter) or use the parser function syntax and separate parameters by pipe characters.

{| class="wikitable"
! URL Parameter
! Description
|-
|<code>DPL_count</code>
|Limit number of pages to show, overwrites the values of the <code>{{DPL|count}}=</code> parameter.
|-
|<code>DPL_offset</code>
|Where to start, n<sup>th</sup> page, overwrites the value of the <code>{{DPL|offset}}=</code> parameter.
|-
|<code>DPL_refresh</code>
|{{note|'''Note:''' This feature was removed in DPL3 version 3.0.0.|error}}
|-
|<code>DPL_findTitle</code>
|Page name to start with, value is passed to {{DPL|titlegt}}= (previously title>= ).
|-
|<code>DPL_toTitle</code>
|Page name to end with, value is passed to {{DPL|titlegt}} (previously title>), which is needed for reverse scroll and which restricts the selection to articles with a page title less or equal to the specified value.
|-
|<code>DPL_fromTitle</code>
|Page name to start after, value is passed to {{DPL|titlelt}} (previously title<), which and restricts the selection to articles with a page title greater or equal to the specified value.
|-
|<code>DPL_scrolldir</code>
|direction of scroll (can be 'up' or 'down').
|}


==Time stamps==

DPL3 queries which return date/time information (e.g., date of last edit of a page) will display this information according to your local timezone (if this is correctly set in your user preferences).


=== Time stamps ===


==Interaction between your wiki text and DPL3 output==
DPL queries which return date/time information (e.g. date of last edit of a page) will display this information according to your local timezone (if this is correctly set in your user preferences).


As mentioned before, DPL3 will insert its output exactly at the position where you placed the DPL3 call. This means that you can put wiki syntax around your DPL3 call, like:
=== Interaction between your wiki text and DPL2 output ===
<pre>
As mentioned before DPL2 will insert its output exactly at the position where you placed the DPL2 call. This means that you can put wiki syntax around your DPL call, like e.g.:
{| class="wikitable"
<pre><nowiki>
{| class=wikitable
|a table field
|a table field
|<DPL>
|<dpl>
linksto=myPage
linksto=myPage
</DPL>
</dpl>
|-
|-
|another table field
|another table field
|...
|...
|}
|}
</nowiki></pre>
</pre>



You could also use html syntax to surround DPL output as in the following example:
You could also use HTML syntax to surround DPL3 output, as in the following example:
<pre><nowiki>
<pre>
<ul>
<ul>
<li>Item1</li>
<li>Item1</li>
Line 165: Line 241:
</li>
</li>
</ul>
</ul>
</nowiki></pre>
</pre>

=== Special Note on ''Self References'' ===


In principle a DPL query could be written in a way that the page containing the query (or the page including a template which contains the query) would be part of the result set. Experience in the past has shown that in some cases this leads to unwanted effects. For instance the page containing the query from a mediawiki point of view contains links to all pages it lists. If your DPL statement contains a "uses" clause you will be astonished to find your own page in all results. The same happens with categories... In addition there were technical problems with self referencing result sets (parser loop references which seemed very hard to solve). So it was decided to skip a self reference in the result set by default.


==Variable replacement in ''mode=userformat''==
<center style="border:1px black solid"><big>'''''Normally DPL does not return its own page in the result.'''''</big></center>


When <code>mode=userformat</code> is selected, DPL3 will not output anything by default; instead, it will look for variables in your parameter input (''listseparators, secseparators, multisecseparators, tablerow'') which it will replace by their corresponding values. For example, <code>%TITLE%</code> will be replaced by the title of an article, <code>%PAGE%</code> will be replaced by the page name. So, if you write something like <br><code><nowiki>[[%PAGE%|%TITLE%]]</nowiki></code>, DPL3 will create a hyperlink to an article.
* The parameter <tt>[[skipthispage]]</tt> gives you control over this behaviour. By setting it to ''no'' you can allow self references in DPL result sets.
* You can suppress back references to a page containing a DPL query by using [[reset]] and/or [[eliminate]].


=== Symbol replacement in ''mode=userformat'' ===


The specification of <code>listseparators</code>, <code>secseparators</code>, and <code>multisecseparators</code> does only make sense in combination with <code>mode=userformat</code>. Therefore, <code>mode=userformat</code> is automatically implied when <code>listseparators</code> is specified. To make the syntax even more comfortable, the simple word <code>format</code> can be used as an alias for <code>listseparators</code>. So:
When mode=userformat is selected, DPL will not output anything by default. Instead it will look for symbols in your input (''listseparators, secseparators, multisecseparators, tablerow'') which it will replace by their corresponding values. For example, <tt>%TITLE%</tt> will be replaced by the title of an article, <tt>%PAGE%</tt> will be replaced by the pagename. So, if you write something like <br><code><nowiki>[[%PAGE%|%TITLE%]]</nowiki></code>, DPL will create a hyperlink to an article.

'''See [[DPL_parameters: Controlling output format#format]] for a complete list of symbols.'''

The specification of <tt>listseparators</tt>, <tt>secseparators</tt>, and <tt>multisecseparators</tt> does only make sense in combination with <tt>mode=userformat</tt>. Therefore <tt>mode=userformat</tt> is automatically implied when <tt>listseparators</tt> is specified. To make the syntax even more comfortable the simple word <tt>format</tt> can be used as an alias for <tt>listseparators</tt>. So:
mode=userformat
mode=userformat
listseparators=a,b,c,d
listseparators=a,b,c,d
is exactly the same as:
is the same as:
format=a,b,c,d
format=a,b,c,d


=== Use of boolean parameters ===
A lot of DPL's parameters have type [http://en.wikipedia.org/wiki/boolean_datatype boolean]. The manual always assumes that 'true' and 'false' are used to set such parameters. As an alternative, you can also use 'yes' and 'no' or '1' and '0' or 'on' and 'off' as with the standard HTML form checkbox input type.


==Use of boolean parameters==
=== Implicit link to [[:Template:Extension DPL]] ===


A lot of DPL3's parameters have type [[w:boolean datatype|boolean]]. The manual always assumes that 'true' and 'false' are used to set such parameters. As an alternative, you can also use 'yes' and 'no' or '1' and '0' or 'on' and 'off' as with the standard HTML form checkbox input type.
Since version 1.7.9 DPL creates an implicit automatic link to <tt>Template:Extension DPL</tt>.
This means that every page containing a DPL statement will automatically create a link to [[:Template:Extension DPL]]. You should create this Template in your wiki. We suggest that you copy the source code from [[:Template:Extension DPL|our version]]. The idea is that via this connection you can easily find out which pages in a wiki contain DPL calls. This may help in maintaining them and it will probably be needed by the dplcache feature which is under construction.


Note that the template does NOT produce any output - so it is practically invisible to the user. If you forget to create the template, however, the user will see a red link to the template.


==Implicit link to [[:Template:Extension DPL]]==
=== Debugging a DPL statement ===
If you want to write a DPL query which produces wiki tables a lot of imagination is required because you must produce correct wiki syntax as the result of your query. And that syntax heavily depends on newlines, escaping of pipe symbols and other nice little things which are easy to get wrong ;-)


Since version 1.7.9, DPL3 creates an implicit automatic link to <code>Template:Extension DPL</code>.
We recommend to use the following parameters to find out what syntax your DPL statement produces:
This means that every page containing a DPL3 statement will automatically create a link to [[:Template:Extension DPL]]. You should create this Template in your wiki. We suggest that you copy the source code from [[:Template:Extension DPL|our version]]. The idea is that via this connection, you can easily find out which pages in a wiki contain DPL3 calls.
resultsheader=«pre»«nowiki»
resultsfooter=«/nowiki»«/pre»


'''Note:''' The template does NOT produce any output—so it is practically invisible to the user. If you forget to create the template, however, the user will see a red link to the template.
The same effect can be achieved with <tt>[[debug]]=5</tt>.


=== Table output ===


==Debugging a DPL3 statement==
We´d also like to point out that there are two special commands named [[table]] and [[tablerow]] which make it quite easy to produce output in table form.


If you want to write a DPL3 query which produces wiki tables, a lot of imagination is required because you must produce correct wiki syntax as the result of your query. And that syntax heavily depends on newlines, escaping of pipe symbols and other nice little things which are easy to get wrong.
=== Scrolling ===


We recommend using the following parameters to find out what syntax your DPL3 statement produces:
DPL supports efficient scrolling through huge result sets.
resultsheader=«pre»«nowiki»
resultsfooter=«/nowiki»«/pre»


The same effect can be achieved with <code>{{DPL|debug}}=5</code>.
The command <tt>scroll=yes</tt> must be given to enable scrolling.


DPL can take certain URL parameters from the command line, like &DPL_fromTitle and &DPL_toTitle. If these arguments are given the commands <tt>title&gt;</tt> and <tt>title&lt;</tt> will implicitly be set. Within the [[resultsheader]] and/or [[resultsfooter]] you can call a template which generates links to fetch the next / previous page.


==Tracking Categories==
See [[DPL Example 027]] for details.
Built-in [[mw:Help:Tracking categories|tracking categories]] include:

{| class="wikitable"
Basically the idea of backward scrolling is that the SQL statement produces a DESCENDING order (with titles below the threshold). Internally DPL buffers the SQl result set and reverses its order. So the user will see a page of entries directly below the threshold, but in ascending order.
!Category Name

!On Use of
If scrolling is enabled, DPL 1.8.0 and later will take a couple of parameters from the URL command line, like <tt>DPL_offset</tt> for instance; these parameters can be accessed within DPL via a special syntax:
|-
* <tt>{%DPL_offset%}</tt>.
|[[:Category:Pages using DynamicPageList3 parser tag]]
or
|<code><nowiki><dpl></dpl></nowiki></code>
* <tt>{%DPL_offset:defaultvalue%}</tt>.
|-

|[[:Category:Pages using DynamicPageList3 Intersection parser tag]]
The variables are:
|<code><nowiki><DynamicPageList></DynamicPageList></nowiki></code>
* DPL_count
|-
* DPL_offset
|[[:Category:Pages using DynamicPageList3 parser function]]
* DPL_refresh (a value of 'yes' will purge the DPL cache)
|<code><nowiki>{{#dpl:}}</nowiki></code>
* DPL_fromTitle (will be passed to title< )
|-
* DPL_toTitle (will be passed to title> )
|[[:Category:Pages using DynamicPageList3 dplnum parser function]]
* DPL_findTitle (will be passed to title>= )
|<code><nowiki>{{#dplnum:}}</nowiki></code>
* DPL_scrolldir (will be used to influence sort order, can be 'up' or 'down')
|-

|[[:Category:Pages using DynamicPageList3 dplvar parser function]]
Thus you could write an article called 'MyPopularArticles' containing a DPL query like:
|<code><nowiki>{{#dplvar:}}</nowiki></code>

|-
<pre><nowiki>
|[[:Category:Pages using DynamicPageList3 dplreplace parser function]]
{{#dpl:execandexit=geturlargs}}
|<code><nowiki>{{#dplreplace:}}</nowiki></code>
<dpl>
|-
category = Country
|[[:Category:Pages using DynamicPageList3 dplchapter parser function]]
count = {%DPL_count:100%}
|<code><nowiki>{{#dplchapter:}}</nowiki></code>
scroll = yes
|-
resultsheader = Showing {%DPL_count:100%} pages starting from page {{#expr:{%DPL_offset%} + 1}}:\n
|[[:Category:Pages using DynamicPageList3 dplmatrix parser function]]
</dpl>
|<code><nowiki>{{#dplmatrix:}}</nowiki></code>
|}


'''Note:''' If the display of tracking categories is not desired on-page, see [[mw:Help:Tracking categories|tracking categories]] for information about using the <code><nowiki>__HIDDENCAT__</nowiki></code> [[mw:Help:Magic words#Behavior switches|magic word]].
</nowiki></pre>


==References==
Calling <tt><nowiki>http://mywebsite/mywiki/index.php?title=MyPopularArticles</nowiki></tt> will give you the first 100 articles in the category. Adding &DPL_offset=100 will give you the next one hundred articles. This mechanism can be used to create a generic page scroll feature - provided you can access the value of <tt>DPL_offset</tt> also in other templates outside DPL. And this is where the <tt>execandexit</tt> command comes in: it stores the URL parameters in a variable which can be accessed via #dplvar.
<references>
<ref name=hitcounters>This feature was completely removed in MediaWiki 1.25, following a request for comment. See [[Hit counters removed]].</ref>
</references>
[[Category:Manual]]

Latest revision as of 05:37, 21 April 2023

Manual General usage and invocation syntax


DynamicPageList3 (DPL3) can be used as a parser extension (<dpl> .... </dpl>) or as a parser function ({{#dpl: .... }}). There is no general rule which one is better. If in doubt, you may want to use the parser function syntax, as it is more powerful.


Sample output

Both of the following examples, which illustrate the difference between using DPL3 as a parser extension and using it as a parser function, will produce a list of all articles which belong to cat1 or cat2 and which contain a reference to myPage. The output of these DPL3 calls would be something like:


Syntax used in this manual

Most examples in this manual typically use the parser function-based syntax, {{#dpl:}} given it is the more flexible syntax. Examples are wrapped in <pre></pre> tags, so the plain wikitext used to create a result can be seen without rendering the result itself.

Most of the manual deals with the explanation of individual parameters. This is independent of the choice between the two variants described above. So, if you read something like

  • parameter = value

you should have in mind that you must either place DPL3 tags around (using a separate line for each parameter) or use the parser function syntax and separate parameters by pipe characters.


DPL3 Invocation syntax

Parser extension (tag) method

The following example would probably be used directly on an article page, but could also be included as part of a template. Parser extensions define a specific tag (in this case <dpl>) and a corresponding end tag (</dpl>). The text between these tags is handed over to the extension module just as it is.


Example syntax
<dpl>
  category = cat1|cat2
  # only pages which contain a link to myPage
  linksto  = myPage
</dpl>


Parsing procedure

Wiki markup expansion does not take place before the commands are handed over to the extension module.

  • This may be useful if you want to pass wiki syntax elements to DPL3 as arguments (see the format option, for example).
  • Magic words like {{PAGENAME}} or {{CURRENTDAY}} cannot be used.
  • Template calls, like {{some template}}, cannot be used as parameters.
  • Parser function calls like {{#if:...|...|...}} cannot be used within arguments.
  • To pass wiki syntax elements to DPL3 as parameters, it is sometimes necessary to enforce a line break. The reason is that wiki syntax depends on line breaks. Instead, use \n or for that purpose.


Syntax features
  • Every parameter assignment (=command) has to be on a separate line.
  • Lines starting with a # will be ignored (comment).
  • Generally the syntax looks fairly simple and intuitive as it doesn't contain special characters (except for the two embracing tags).
  • Tag case doesn't matter, so it can also be written <dpl>.
  • Often, there is no need to have macro expansion within the parameter list.
  • In the example above, the pipe character (which is used to define a logical OR between the two categories) can be written as it is. The name of the page (myPage), however, must be a hard-coded constant.


Parser function method

This example would be used inside a template, and uses the variable {{{1}}} passed to the template, which would be set to myPage here. Parser functions look like templates which start with a hash character (#). They are more closely integrated with the wiki system. They are more powerful, but their syntax looks a bit more complicated. The text between these tags is pre-parsed to expand wiki mark-up before being handed over to the extension module.


Example syntax:

{{#dpl: category = cat1{{!}}cat2 | linksto = {{{1}}} }}

or

{{#dpl:
  |category = cat1¦cat2
  |linksto  = {{{1}}}
}}


Parsing procedure

Wiki markup expansions (not the final conversion to HTML) take place before the commands are handed over to the extension module.

  • Magic words like {{PAGENAME}} or {{CURRENTDAY}} can be used.
  • Template calls, like {{some template}}, can be used as parameters.
  • Parser function calls like {{#if:...|...|...}} can be used within arguments, though they must be formatted differently ²{#if:...¦...¦...}²


Syntax features

  • To use wiki characters as arguments, they must be escaped.
    • It is possible to use the Magic Word {{!}} which 'hides' the pipe from the MediaWiki parser, ensuring that it is not considered until after other items have been expanded, though if multiple need to be used this can make your statements harder to read.
    • With DPL3 it is also possible to use the symbol ¦ instead of |; this is very intuitive, and maybe it could be adopted by MediaWiki in general...but be careful: it must be inserted by copy-and-paste from here (or from an HTML symbol or extended ASCII table like Windows' Character Map) as normally a keyboard will not have it available (even worse: on some keyboards the standard pipe character is printed in a way that it looks more like the "broken pipe").
  • The text can (but needs not) be written in one line of text, parameters are separated by pipe characters.
  • What was said before regarding explicit line breaks also holds true for parser function syntax, i.e., the special symbols \n or must be used to insert an explicit linefeed character into the wiki output stream if wiki symbols are used which must stand at the beginning of a line.


Notes:

  • The pipe character, which is used to define a logical OR for the two categories, must be represented as a Magic Word {{!}} which 'hides' the pipe from the MediaWiki parser, ensuring that it is not considered until after other items have been expanded. The second example shows that the ¦ character acts as an alternative to this somewhat awkward notation.
  • The second example is not literally equivalent to the first one, as there is an additional pipe character before the first parameter. Technically, this creates an additional empty parameter, but as empty parameters are silently ignored by DPL3 it makes no difference.


Special note on Self References

In principle, a DPL3 query could be written in a way that the page containing the query (or the page including a template which contains the query) would be part of the result set. Experience in the past has shown that in some cases this leads to unwanted effects. For instance, the page containing the query from a MediaWiki perspective contains links to all pages it lists. If your DPL3 statement contains a "uses" clause, you will be astonished to find your own page in all results. The same happens with categories... In addition, there were technical problems with self referencing result sets (parser loop references, which seemed very hard to solve). So, it was decided to skip a self reference in the result set by default.


Important: DPL3 does not normally return its own page (a self link/reference) in the result set. To include a page that references itself in the result, you must use skipthispage


You can suppress back references to a page containing a DPL3 query by using reset and/or eliminate.


Characters with special meaning

Occasionally, it is necessary to use a character as "plain data" at a place where it normally has a syntactical meaning. MediaWiki is not very clean at character escaping in general. So, we had to define our own way in the jungle of "character escaping":

DPL3 escape character MediaWiki character Typical use
» > Call another MediaWiki extension into a parameter of a DPL3 call, or create a gallery <gallery></gallery> using DPL3's parser function syntax.
« <
²{ {{ Call a template or parser function within the 'article loop' of DPL3's parser function syntax; this is especially useful for nesting DPL3 calls (DPL recursion).
}}
¦ |
newline Inserts a line break into DPL3's wikitext output, to allow proper parsing of first-character syntax (such as {| * # : |} ;)
\n newline

DPL3's mechanism of replacing %xx% variables then can be used to modify the arguments of that call before it will be resolved. Most DPL3 users will not need this, but for some advanced uses of DPL3 it is a real help.


Built-in variables

Within a DPL3 statement, you can use some symbols (called variables in this manual) which are implicitly set by DPL3. Some variables can only be used in the header or footer. {{#lst:Controlling output format|formatvariables}}

Variable Description
%SECTION% The page name and its included section anchor Page Name#SectionName. Corresponds to include=#SectionName (when a page section is included by name). It currently appears that %SECTION% can only be used in secseparators.
%PFUNC% The name of the parser function, set when include is used to look for parser function calls in an article or result set. This variable requires a corresponding include statement and is not very robust, it cannot handle nested parser functions properly. %PFUNC% is only applicable to the template for which the parser function and its parameters are passed (under their normal names or numbers).
%TAG% The name of the parser extension (tag), set when include is used to look for parser extension (tag) calls an article or result set. This variable requires a corresponding include statement and is not very robust, it cannot handle nested parser functions properly. %TAG% is only applicable to the template for which the parser extension information is passed.
%TAGBODY% The body content (as-is, including line breaks) of the parser extension (tag), set when include is used to look for parser extension calls an article or result set. This variable requires a corresponding include statement and is not very robust, it cannot handle nested parser functions properly. %TAGBODY% is only applicable to the template for which the parser extension information is passed.


Scrolling/URL Parameters

DPL3 supports efficient scrolling through huge result sets. Basically, the idea of backward scrolling is that the SQL statement produces a DESCENDING order (with titles below the threshold). Internally, DPL3 buffers the SQL result set and reverses its order. So, the user will see a page of entries directly below the threshold, but in ascending order.

The command scroll=yes must be given to enable scrolling.


Scroll/URL syntax

If scrolling is enabled, DPL3 1.8.0 and later will take some parameters from the URL command line (e.g., like DPL_offset); these parameters can be accessed within DPL3 via a special syntax:

  • {%DPL_offset%}.

or

  • {%DPL_offset:defaultvalue%}.

Within the DPL3 statement, you can access URL parameters via

 {%DPL_xxx%}

If a parameter is not set in the URL, DPL3 will assume an empty string. Instead, you can define a default value by using a colon:

{%DPL_xxx:yyy%}

In this case, DPL3 will use 'yyy' if the parameter DPL_xxx is not specified on the URL command line.


Note: There is a template called Template:DPL3 scroll which uses DPL_offset and DPL_count to provide a generic page scrolling method for huge result sets, where there is an expected number of results. See scroll for more information.


Scroll/URL parameters

When scrolling is enabled, DPL will interpret the following special parameters in the URL.

URL Parameter Description
DPL_count Limit number of pages to show, overwrites the values of the count= parameter.
DPL_offset Where to start, nth page, overwrites the value of the offset= parameter.
DPL_refresh
Note: This feature was removed in DPL3 version 3.0.0.
DPL_findTitle Page name to start with, value is passed to titlegt= (previously title>= ).
DPL_toTitle Page name to end with, value is passed to titlegt (previously title>), which is needed for reverse scroll and which restricts the selection to articles with a page title less or equal to the specified value.
DPL_fromTitle Page name to start after, value is passed to titlelt (previously title<), which and restricts the selection to articles with a page title greater or equal to the specified value.
DPL_scrolldir direction of scroll (can be 'up' or 'down').


Time stamps

DPL3 queries which return date/time information (e.g., date of last edit of a page) will display this information according to your local timezone (if this is correctly set in your user preferences).


Interaction between your wiki text and DPL3 output

As mentioned before, DPL3 will insert its output exactly at the position where you placed the DPL3 call. This means that you can put wiki syntax around your DPL3 call, like:

  {| class="wikitable"
  |a table field
  |<dpl>
     linksto=myPage
   </dpl>
  |-
  |another table field
  |...
  |}


You could also use HTML syntax to surround DPL3 output, as in the following example:

<ul>
  <li>Item1</li>
  <li>Item2
    <DPL>
      ...parameters...
    </DPL>
  </li>
</ul>


Variable replacement in mode=userformat

When mode=userformat is selected, DPL3 will not output anything by default; instead, it will look for variables in your parameter input (listseparators, secseparators, multisecseparators, tablerow) which it will replace by their corresponding values. For example, %TITLE% will be replaced by the title of an article, %PAGE% will be replaced by the page name. So, if you write something like
[[%PAGE%|%TITLE%]], DPL3 will create a hyperlink to an article.


The specification of listseparators, secseparators, and multisecseparators does only make sense in combination with mode=userformat. Therefore, mode=userformat is automatically implied when listseparators is specified. To make the syntax even more comfortable, the simple word format can be used as an alias for listseparators. So:

mode=userformat
listseparators=a,b,c,d

is the same as:

format=a,b,c,d


Use of boolean parameters

A lot of DPL3's parameters have type boolean. The manual always assumes that 'true' and 'false' are used to set such parameters. As an alternative, you can also use 'yes' and 'no' or '1' and '0' or 'on' and 'off' as with the standard HTML form checkbox input type.


Implicit link to Template:Extension DPL

Since version 1.7.9, DPL3 creates an implicit automatic link to Template:Extension DPL. This means that every page containing a DPL3 statement will automatically create a link to Template:Extension DPL. You should create this Template in your wiki. We suggest that you copy the source code from our version. The idea is that via this connection, you can easily find out which pages in a wiki contain DPL3 calls.

Note: The template does NOT produce any output—so it is practically invisible to the user. If you forget to create the template, however, the user will see a red link to the template.


Debugging a DPL3 statement

If you want to write a DPL3 query which produces wiki tables, a lot of imagination is required because you must produce correct wiki syntax as the result of your query. And that syntax heavily depends on newlines, escaping of pipe symbols and other nice little things which are easy to get wrong.

We recommend using the following parameters to find out what syntax your DPL3 statement produces:

 resultsheader=«pre»«nowiki»
 resultsfooter=«/nowiki»«/pre»

The same effect can be achieved with debug=5.


Tracking Categories

Built-in tracking categories include:

Category Name On Use of
Category:Pages using DynamicPageList3 parser tag <dpl></dpl>
Category:Pages using DynamicPageList3 Intersection parser tag <DynamicPageList></DynamicPageList>
Category:Pages using DynamicPageList3 parser function {{#dpl:}}
Category:Pages using DynamicPageList3 dplnum parser function {{#dplnum:}}
Category:Pages using DynamicPageList3 dplvar parser function {{#dplvar:}}
Category:Pages using DynamicPageList3 dplreplace parser function {{#dplreplace:}}
Category:Pages using DynamicPageList3 dplchapter parser function {{#dplchapter:}}
Category:Pages using DynamicPageList3 dplmatrix parser function {{#dplmatrix:}}

Note: If the display of tracking categories is not desired on-page, see tracking categories for information about using the __HIDDENCAT__ magic word.

References

Cite error: <ref> tag with name "hitcounters" defined in <references> has group attribute "" which does not appear in prior text.