Jump to content
This wiki has been automatically closed because there have been no edits or log actions made within the last 60 days. If you are a user (who is not the bureaucrat) that wishes for this wiki to be reopened, please request that at Requests for reopening wikis. If this wiki is not reopened within 6 months it may be deleted. Note: If you are a bureaucrat on this wiki, you can go to Special:ManageWiki and uncheck the "Closed" box to reopen it.

General usage and invocation syntax: Difference between revisions

m
putting things back where they were before un-privating again
imported>FrozenPlum
imported>FrozenPlum
m (putting things back where they were before un-privating again)
Line 1:
{{note|This page is in development, some content may be incorrect, outdated or otherwise misleading.|warn}}
{{DPL manual|section=General usage and invocation syntax}}
 
'''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.
 
;Sample output
Line 26 ⟶ 27:
* This may be useful if you want to pass wiki syntax elements to DPL3 as arguments (see the {{dpl3|format}} option, for example).
* [[mw:Magic words|Magic words]] like <code><nowiki>{{PAGENAME}}</nowiki></code> or <code><nowiki>{{CURRENTDAY}}</nowiki></code> '''cannot''' be used.
* Template calls, like <code><nowiki>{{some template}}</nowiki></code>, cannot be used as parameters.
* 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 <code>\n</code> or <code>¶</code> for that purpose.
Line 38 ⟶ 39:
 
==Parser function method==
This example would be used inside a template, and uses the variable <code><nowiki>{{{1}}}</nowiki></code> 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.'''
 
;Example syntax
Line 55 ⟶ 56:
Wiki markup expansions (not the final conversion to HTML) take place before the commands are handed over to the extension module.
* Magic words like <code><nowiki>{{PAGENAME}}</nowiki></code> or <code><nowiki>{{CURRENTDAY}}</nowiki></code> '''can''' be used.
* Template calls, like <code><nowiki>{{some template}}</nowiki></code>, can be used as parameters.
* Parser function calls like <code><nowiki>{{#if:...|...|...}}</nowiki></code> can be used within arguments.
 
;Syntax features
* 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.
** 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 aan 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 <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 <code>¦</code> 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 DPL it makes no difference.
 
===#dplchapter===
Line 73 ⟶ 74:
 
==Characters with special meaning==
Sometimes it is necessary to use a character as "plain data" at a place where it normally has a syntactical meaning. MediawikiMediaWiki 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 !! MediawikiMediaWiki character!! Typical use
|-
| align=center | <code>'''»'''</code> || align=center | &gt; || rowspan=2 | Call another MediaWiki extension into a parameter of a DPL call
Line 97 ⟶ 98:
 
==Built-in variables==
Within a DPL statement, you can use some [[DPL format variables|variables]] which are implicitly set by DPL.
Example: %TITLE%, %PAGE%
 
Line 103 ⟶ 104:
 
==URL parameters==
DPL understands a couple of parameters which can be passed via ana URL specification. These URL-parameters all start with DPL_:
* DPL_count: influences the {{dpl3|count}} parameter (in fact, it overwrites the value specified within the DPL statement)
* DPL_offset: influences the {{dpl3|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
Line 117 ⟶ 118:
would display ''MyPage'' and set the offset parameter to a value of ''20''.
 
Within the DPL statement, you can access URL parameters via
{%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:
{%DPL_xxx:yyy%}
In this case, DPL 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.
 
==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.
 
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
Line 133 ⟶ 134:
 
==Time stamps==
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).
 
==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 DPL call, like e.g.,:
<pre><nowiki>
{| class=wikitable
Line 149 ⟶ 150:
</nowiki></pre>
 
You could also use htmlHTML syntax to surround DPL output, as in the following example:
<pre><nowiki>
<ul>
Line 162 ⟶ 163:
 
==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.
 
<center style="border:1px black solid"><big>'''''Normally DPL does not return its own page in the result.'''''</big></center>
Line 170 ⟶ 171:
 
==Symbol replacement in ''mode=userformat''==
When mode=userformat is selected, DPL will not output anything by default.; Insteadinstead, it will look for symbols in your 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 pagename. So, if you write something like <br><code><nowiki>[[%PAGE%|%TITLE%]]</nowiki></code>, DPL will create a hyperlink to an article.
 
'''See [[Extension:DPL3/Parameters: Controlling output format#format]] for a complete list of symbols.'''
 
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:
mode=userformat
listseparators=a,b,c,d
Line 184 ⟶ 185:
 
==Implicit link to [[:Template:Extension DPL]]==
Since version 1.7.9, DPL creates an implicit automatic link to <code>Template:Extension DPL</code>.
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.
 
Note that the template does NOT produce any output - sooutput—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 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 ;-).
 
We recommend to useusing the following parameters to find out what syntax your DPL statement produces:
resultsheader=«pre»«nowiki»
Line 207 ⟶ 208:
The command <code>scroll=yes</code> 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 <code>title&gt;</code> and <code>title&lt;</code> will implicitly be set. Within the {{dpl3|resultsheader}} and/or {{dpl3|resultsfooter}} you can call a template which generates links to fetch the next / previous page.
 
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.
 
If scrolling is enabled, DPL 1.8.0 and later will take a couple of parameters from the URL command line, like <code>DPL_offset</code> for instance; these parameters can be accessed within DPL via a special syntax:
Line 225 ⟶ 226:
* DPL_scrolldir (will be used to influence sort order, can be 'up' or 'down')
 
Thus, you could write an article called 'MyPopularArticles' containing a DPL query like:
 
<pre><nowiki>
Line 238 ⟶ 239:
</nowiki></pre>
 
Calling <code><nowiki>http://mywebsite/mywiki/index.php?title=MyPopularArticles</nowiki></code> 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 - providedfeature—provided you can access the value of <code>DPL_offset</code> also in other templates outside DPL. And this is where the <code>execandexit</code> command comes in: it stores the URL parameters in a variable which can be accessed via #dplvar.
 
[[Category:Manual]]
<!-- Extension prefix in other languages:
 
[[de:Erweiterung:{{subst:BASEPAGENAME}}]]
[[es:Extensión:{{subst:BASEPAGENAME}}]]
[[fr:Extension:{{subst:BASEPAGENAME}}]]
[[it:Estensione:{{subst:BASEPAGENAME}}]]
[[nl:Uitbreiding:{{subst:BASEPAGENAME}}]]
[[pl:Rozszerzenie:{{subst:BASEPAGENAME}}]]
[[pt:Extensão:{{subst:BASEPAGENAME}}]]
[[ru:Расширение:{{subst:BASEPAGENAME}}]]
[[zh:扩展:{{subst:BASEPAGENAME}}]]
-->
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.