Difference between revisions of "DPL:Manual - DPL parameters: Other parameters"

From FollowTheScore
Jump to: navigation, search
(debug)
(execandexit)
 
(31 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Type:Manual|section=Other parameters}}
+
{{Type Manual|section=Other parameters}}
 +
 
 +
===updaterules===
 +
 
 +
{{DPL parameter
 +
|name  = updaterules
 +
|purpose= define a set of rules which are executed to perform an update on selected articles (''bulk update'' or ''template value editing'')
 +
}}
 +
 
 +
Syntax:
 +
 
 +
<code>updaterules=
 +
    <i>rule</i>;
 +
    ...
 +
    <i>rule</i>;
 +
</code>
 +
 
 +
Where rule is one of the following:
 +
 
 +
* rules for batch update of articles 
 +
    replace  ''pattern'';
 +
      by        ''replacement'';
 +
    before    ''pattern'';
 +
      insert    ''text'';
 +
    after    ''pattern'';
 +
      insert    ''text'';
 +
 
 +
* rules for interactive update of articles
 +
    template  ''template name'';
 +
    legend    ''legend article name'';
 +
    table    ''table format'';
 +
    editform  ''form parameters'';
 +
    action    ''form action'';
 +
    hidden    ''value'';
 +
    submit    ''submit button'';
 +
    commit    ''commit button'';
 +
    parameter ''parameter name'';
 +
      value      ''value'';
 +
      format    ''display format'';
 +
      tooltip    ''text'';
 +
      optional  ''value'';
 +
      afterparm  ''parameter name'';
 +
 
 +
* common rules
 +
    summary  ''edit summary text'';
 +
    exec      ''value'';
 +
 
 +
The first group of rules is intended for batch updates of articles. A DPL query can select a group of articles and perform updates like inserting a piece of text at a certain position or changing text portions based on regular expressions.
 +
 
 +
The second group of rules is intended for interactive form-based editing of template values.
 +
 
 +
The third group of rules is common to both other groups and controls the update process.
 +
 
 +
The <tt>updaterules</tt> feature is intended for wiki expert users only. It is recommended that articles usind this statement are 'protected':
 +
 
 +
 
 +
==== Rules for batch update in detail: ====
 +
 
 +
===== replace ''pattern''; =====
 +
Defines a regular expression which matches text portions that shall be replaced. It is in the responsibility of the user to provide enclosing characters for the regexp; modifiers line 'U' or 'm' can be used.
 +
 
 +
===== by ''replacement''; =====
 +
Defines the replacement for the above pattern; back references like \1 can be used.
 +
 
 +
===== before ''pattern''; =====
 +
 
 +
Defines locations where text will be inserted. The location(s) will be immediately before the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will be performed.
 +
 
 +
The regexp will implicitly be enclosed in slashes. Hence literal slash characters must be escaped by backslashes.
 +
 
 +
===== after ''pattern''; =====
 +
 
 +
Defines locations where text will be inserted. The location(s) will be immediately after the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will be performed.
 +
 
 +
The regexp will implicitly be enclosed in slashes. Hence literal slash characters must be escaped by backslashes.
 +
 
 +
===== insert ''text''; =====
 +
 
 +
Defines the text to be inserted.
 +
 
 +
A DPL statement may contain replacement, insertion before and after at the same time.
 +
  replace /([a-z]+])-cat/;
 +
  by      \1-dog;
 +
  before foo;
 +
  insert bar;
 +
  after  foo;
 +
  insert bar2;
 +
 
 +
Only one 'replace'-'by' sequence, one insertion 'before' and one insertion 'after' can be specified. 'replace' is always executed first, followed by 'insert before' and 'insert after', regardless of the sequence in which the rules appear in the DPL source ´text.
 +
 
 +
==== Rules for interactive update in detail: ====
 +
 
 +
===== template ''template name''; =====
 +
 
 +
The name of the template; the prefix "Template:" must be given.
 +
 
 +
 
 +
 
 +
 
 +
be inserted. The location(s) will be immediately before the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will be performed.
 +
 
 +
The regexp will implicitly be enclosed in slashes. Hence literal slash characters must be escaped by backslashes.
 +
 
 +
 
 +
 
 +
a regular expression
 +
    after    ''pattern'';
 +
    insert    ''text'';
 +
    replace  ''pattern'';
 +
    by        ''replacement'';
 +
 
 +
 
 +
 
 +
 
 +
 
 +
For safety reasons the update statements will only be performed if "exec yes" is specified. So, leaving this away, you can check what would happen if the update were to be executed.
 +
 
 +
Note that if "exec yes" is present the update will be performed each time the page is renderes which contains the DPL statement  with the <tt>updaterules</tt>. So it is advisable to set "exec yes" only via a command line argument and not as part of the statioc article text. Thus you stay in control when the update happens. Typically one would use an URL parameter like ''DPL_arg1'' for that purpose.
 +
 
 +
The size of the form fields will dapt to the size of the displayed content.
 +
 
 +
 
 +
 
 +
 
 +
To make the use of the <tt>updaterules</tt> feature easier we provide a [[Template:Bulk Update|special user interface]].
 +
 
 +
''text'' is plain text; ''replacement'' is text which may contain references (like \1) to the matching ''pattern'' (provided that this pattern contains match groups).
 +
 
 +
===deleterules===
 +
{{DPL parameter
 +
|name  = deleterules
 +
|purpose= allow the mass deletion of wiki pages
 +
}}
 +
 
 +
<code>deleterules=
 +
    reason <i>text</i>;
 +
    exec true;
 +
</code>
 +
 
 +
This command is experimental at the moment.
 +
 
 +
This will delete the selected pages; If "exec true" is missing, nothing will happen.
  
 
===goal===
 
===goal===
Line 37: Line 178:
 
Syntax:
 
Syntax:
  
<code>allowcachedresults=<i>true</i></code>
+
<code>allowcachedresults=<i>true | false | yes+warn</i></code>
  
 
Explanation:
 
Explanation:
Line 48: Line 189:
  
 
If you allow cached results you can still enforce DPL to produce a correct result via using "&action=purge" in the command line.
 
If you allow cached results you can still enforce DPL to produce a correct result via using "&action=purge" in the command line.
 +
 +
'yes+warn' will use the cache; in addition the result will contain a warning indicating that the result may be out-dated. This is achieved by including the template ''DPL Cache Warning'' into the result header. It is up to you to provide a useful text under that name, see e.g. [[Template:DPL Cache Warning]].
  
 
===reset===
 
===reset===
Line 65: Line 208:
 
*''all'' &mdash; a synonym for all of the above
 
*''all'' &mdash; a synonym for all of the above
  
Note that '''''reset'' must be the one and only parameter in a separate DPL statement!'''
+
The output of a DPL statement typically creates links to all pages which are part of the result set. The inclusion of contents from other pages via DPL (using 'include') normally has the consequence
 +
* that the page containing the DPL query becomes part of the categories of the transcluded page
 +
* that it shares ('adopts') their use of templates
 +
* that it shares their references to images
 +
* that it shares their references to other articles.
 +
 
 +
In some cases this may be useful. But in many cases this is not wanted. Especially when you use DPL to create a printable document which contains the full text of other articles you will probably not want to duplicate all links, template uses etc. of those articles.
 +
 
 +
The <tt>reset</tt> parameter will suppress all or some of the effects described above.
 +
 
 +
There are some subtle differences here depending on the mode in which you use DPL. These differences affect the question how links, and categories etc. are treated which are direct part of the document containing the DPL query.
 +
Example:
 +
<pre><nowiki>
 +
[[Category:Q Cat]] linking to [[Q Link]] and showing [[Image:Q Image]] and using {{Q Template}}
 +
... DPL query which includes contents from other articles.
 +
    assuming that this contents contains links and images,
 +
              that it uses templates and thatthe articles are part of one or more categories
 +
    RESET statement at the end of the DPL query with one or more of 'categories,templates,images,links'
 +
...
 +
</nowiki></pre>
 +
 
 +
<u>In parser extension mode (DPL '''tag''' like &lt;DPL&gt;):</u>
 +
;reset=categories: will ignore categories of included contents but keep 'own' categories like 'Q Cat'.
 +
;reset=images: will throw away references to images contained in included contents but keep 'own' images like 'Q Image'.
 +
;reset=templates: will ignore templates used in included contents but keep 'own' template usage ('Q Template').
 +
;reset=links: will throw away all references to other pages, i.e. links contained in included contents and links like 'Q Link' will be ignored. This means that all links can be used in the normal "FORWARD" way, but no "BACKLINKS" are available for them.
 +
 
 +
If you want to avoid the above described effect of <tt>reset</tt> on your 'own' links you can use <tt>[[eliminate]]</tt>. But you should know that ''eliminate'' is rather expensive in terms of computer power as it does a second parse for all included contents.
 +
 
  
The output of a DPL statement typically creates links to all pages which are part of the result set. The inclusion of contents from other pages via DPL (using 'include') normally has the consequence that the page containing the DPL query becomes part of the categories of the transcluded page and that it shares its categories and references to images and other articles. '''This is in many cases unwanted.'''
+
<u>In parser fuction mode ('''<nowiki>{{#DPL:....}}</nowiki>'''):</u>
  
If you use a ''separate DPL query after the last DPL query of your article'' which only has the parameter 'reset' you can prevent these effects. If you use ''all'' or ''links'' in that statement, <big>'''no link from your page to other pages will be recorded in the database'''</big>, which means that these links work in forward direction but cannot be navigated backwards. This affects not only the links produced by the DPL statement or contained in transcluded contents but simply '''all''' links (=references to other articles) of the page containing the DPL-query with the 'reset' statement.
+
;reset=categories: will ignore all categories
 +
;reset=images: will throw away all references to images
 +
;reset=templates: will ignore all template invocations
 +
;reset=links: will throw away all references to other pages
 +
 
 +
As you see, using <tt>reset</tt> in parser function mode will clear everything regardless whether it comes from included contents or whether it is direct part of the document containing the DPL query.
 +
 
 +
If you want to avoid the above described effect of <tt>reset</tt>, you can use <tt>[[eliminate]]</tt>. But you should know that ''eliminate'' is rather expensive in terms of computing power as it does a second parse for all included contents. The extra parser step is conducted as soon as you specify <tt>eliminate</tt>. In terms of extra processing needed it does not make a difference whether you specify one or more arguments for the 'eliminate' command.
 +
 
 +
If you have '''more than one DPL query''' in a document the effects will depend on the exact mode (parser extension or parser function mode), on the sequence of the statements and on the presence of 'reset' or 'eliminate' statements in each of the queries and on their individual arguments. As this is a very rare case we only give a simple rule of thumb here: Once you have used 'reset' in parser function mode or 'reset=links' in parser extension mode the effect of these statements will dominate the rest.
 +
 
 +
 
 +
=== fixcategory ===
 +
 
 +
{{DPL parameter
 +
|name  = fixcategory
 +
|purpose= assign the article containing a DPL statement to a category although <tt>reset</tt> was used.
 +
}}
 +
 
 +
Syntax:
 +
<code>fixcategory=<i>category name</i></code>
 +
 
 +
Use multiple commands to assign the article to more than one category.
 +
 
 +
If you use <tt>reset=all</tt> or <tt>reset=categories</tt> the article containing your DPL statement will not be recorded in the mediawiki link database. This may be quite useful if your article transcludes content from other pages. Without the <tt>reset</tt> command your article would appear in a category if you included a text portion containing an assignment to that category.
 +
 
 +
As a side effect of using <tt>reset=all</tt> your article will not appear in a category even if you literally assign it to one.
 +
The <tt>fixcategory</tt> allows you to make a category assignment which is not blocked by the [[reset]] command.
 +
 
 +
===eliminate===
 +
 
 +
{{DPL parameter
 +
|name  = eliminate
 +
|purpose= suppress references to pages, templates, images, categories in DPL output
 +
}}
  
If you use ''categories,templates,images'' only the effects coming from transcluded contents will be eliminated.
+
Syntax:
  
It is recommended that you add
+
<code>eliminate=keyword,..</code>
                                  <nowiki>{{#dpl:reset=all}}</nowiki>
 
            or at least
 
                                  <nowiki>{{#dpl:reset=categories,templates,images}}</nowiki>  
 
            to pages
 
            which primarily serve the purpose to show the result of a DPL query.
 
  
Example:
+
Where <tt>keyword</tt> is one of:
  
<pre><nowiki>
+
* <tt>categories</tt>
--- MyQueryArticle ---
+
* <tt>templates</tt>
a link to a [[page]]
+
* <tt>images</tt>
[[Category:cat1]]
+
* <tt>links</tt>
{{#dpl: some query .., possibly using the 'include' statement  }}
+
* <tt>all</tt> &mdash; a synonym for all of the above
a {{template}} being used
 
{{#dpl: another query .., possibly using the 'include' statement  }}
 
an [[Image:xx]]
 
{{#dpl:reset=all}}
 
a link to [[another page]]
 
{{another template}} being used
 
[[Image:YY]]
 
[[Category:cat2]]
 
</nowiki></pre>
 
  
You will see a page which contains links to two pages ('page' and 'another page') and two images, which uses two templates and contains a lot of links as the result of your DPL queries. The contents transcluded by the DPL statements may use OTHER/ADDITIONAL templates, it may contain more images, page links and template references.
+
The output of a DPL statement typically creates links to all pages which are part of the result set. The inclusion of contents from other pages via DPL (using <tt>[[include]]</tt>) normally has these consequences:
 +
* the page containing the DPL query becomes part of the categories of the transcluded page
 +
* shares ('adopts') their use of templates
 +
* shares their references to images
 +
* shares their references to other articles
  
The mediawiki SQL database will, however, not reflect all of the above ('''which it would normally do''' if the 'reset' DPL query was missing).: It will not contain any references from ''myQueryArticle'' to other pages in the wiki (not even the references to ''page'' or ''another page''. It will not contain references to images or templates which happen to be inside transcluded contents. It will, however, contain references to ''template'', ''another template'', ''Image:xx'' and ''Image:YY''. ''MyQueryArticle'' will be part of categories ''cat1'' and ''cat2'' but it will NOT be part of categories to which the articles belong which occur in the DPL result set.
+
In some cases this may be useful. But in many cases this is not wanted. Especially when you use DPL to create a printable document which contains the full text of other articles you will probably not want to duplicate all links, template uses etc. of those articles.
  
<ul>KNOWN BUG:</ul>
+
The <tt>eliminate</tt> parameter will suppress all or some of the effects described above.
  
<tt>reset=categories</tt> will NOT remove categories that were assigned by transcluded contents if the DPL statement doing the transclusion used the '''parser function syntax'''. The reason for this is that the output of a DPL call will '''not be parsed''' by the mediawiki parser at the end of a DPL call. In contrary, parsing of DPL output is left to the final parsing call for the whole document because this allows to embed DPL output into syntactic constructs which are created outside the DPL call (e.g. a wikitable where the DPL call contributes some rows). As a consequence of this category assignments which are created during that final parser call could only be removed AFTER the document processing, but not by a command sitting inside the document text itself.
+
For further explanation see <tt>[[reset]]</tt>.
  
On the other hand DPL output is directly processed by the parser if parser extension syntax (DPL tag) is used. In these cases the '''reset''' works as you would expect.
+
Please note that the use of <tt>eliminate</tt> needs a considerable amount of extra computing power as it performs a second parser step for each included document.
  
 
===debug===
 
===debug===
Line 117: Line 312:
  
 
<code>debug=<i>n</i></code>, where ''n'' is one of:
 
<code>debug=<i>n</i></code>, where ''n'' is one of:
*''0'' &mdash; silent mode, shows nothing
+
* ''0'' &mdash; silent mode, shows nothing
*''1'' &mdash; quiet mode, shows (fatal) errors
+
* ''1'' &mdash; quiet mode, shows (fatal) errors
*''2'' &mdash; default mode, like 1 + shows warnings; &mdash; '''(default)'''
+
* ''2'' &mdash; default mode, like 1 + shows warnings; &mdash; '''(default)'''
*''3'' &mdash; verbose mode, like 2 + shows SQL query.  
+
* ''3'' &mdash; verbose mode, like 2 + shows SQL query.  
*''4'' &mdash; for internal use only
+
* ''4'' &mdash; for internal use only
*''5'' &mdash; show Wiki text output from DPL instead of parsed wiki text
+
* ''5'' &mdash; show Wiki text output from DPL instead of parsed wiki text
 +
* ''6'' &mdash; show SQL query but DO NOT EXECUTE the query.
 +
 
 
'''If you use debug param but not in first position in the DPL element, the new debug settings are not applied before all previous parameters have been parsed and checked.''' This will generate a warning for <code>debug=2</code> and above.
 
'''If you use debug param but not in first position in the DPL element, the new debug settings are not applied before all previous parameters have been parsed and checked.''' This will generate a warning for <code>debug=2</code> and above.
  
Line 138: Line 335:
  
 
DPL debug messages are translatable in <code>DynamicPageList2.i18n.php</code>. See also [[#Internationalization]].
 
DPL debug messages are translatable in <code>DynamicPageList2.i18n.php</code>. See also [[#Internationalization]].
 +
 +
'debug=1' will suppress warning messages (e.g. if the result set of a DPL query is empty). As an alternative, you can use the <tt>[[suppresserrors]]</tt> statement.
 +
 +
 +
===execandexit===
 +
 +
{{DPL parameter
 +
|name  = execandexit
 +
|purpose= process the command given as an argument and then exit immediately.
 +
}}
 +
 +
Syntax:
 +
 +
<code>execandexit=<i>wiki text</i></code>
 +
<br>or<br>
 +
<code>execandexit=<i>geturlargs</i></code>
 +
 +
If no wiki text is given the command will be ignored. Otherwise DPL will output the wiki text and exit immediately.
 +
Note that the wiki text may be a parser function call which evaluates to an empty string.
 +
 +
The special word ''geturlargs'' can be used as a wiki text to transform URL arguments into variables which can then be accessed via #var (if the Variables extension is installed) or via #dplvar.
 +
 +
Purpose:
 +
 +
Using this command you can prevent DPL from executing a database query; this may be useful if a necessary parameter was not given by the user. Note that an ''#if'' function call would NOT help in that case because ''#if'' evaluates its complete content before taking the "if" or the "else" path. So, emebdding a DPL call within a #if is much less efficient than using the ''execandexit'' function.
 +
 +
A typical use would look like this (note the double pipe symbols within the #if.
 +
Calling the following page with &cat=Country would list countries, omitting the &cat parameter would trigger the error text mnessage (without DPL going to the database):
 +
<pre><nowiki>
 +
{{#dpl:execandexit=geturlargs}}
 +
{{#dpl:
 +
| execandexit    = {{#if:{{#dplvar:cat}}||please specify a category via &cat= in the URL!}}
 +
| resultsheader  = pages in category {{#dplvar:cat}}:\n
 +
| noresultsheader = there are no pages in category {{#dplvar:cat}}.\n
 +
| count          = 5
 +
| category        = {{#dplvar:cat}}
 +
}}
 +
</nowiki></pre>
 +
 +
See also: [[Template:Extension DPL scroll]] and [[DPL Example 020]] and [[Scrolling]]
 +
 +
Note <tt>execandexit</tt> acts like a short-circuit evaluation. This means, for example, that successive statements to influence caching behaviour (like [[allowcachedresults]]) will not be interpreted.
 +
 +
=== dplcache ===
 +
 +
{{DPL parameter
 +
|name  = dplcache
 +
|purpose= put the result of a DPL query in a special cache from where it is served until the cache expires
 +
}}
 +
 +
Syntax:
 +
 +
<code>dplcache=<i>name</i></code>
 +
 +
''name'' must be a symbol which is unique for the DPL statement WITHIN your page. As you will in most cases have only one DPL statement in your page, a simple symbol like '1' will be o.k.
 +
 +
Purpose:
 +
 +
Save processing time and avoid unnecessary resource consumption. You can decide how long the result of a DPL query shall be considered to be reasonably 'valid'. This may be longer or shorter than the ParserCacheExpiration time which you have configured in your LocalSettings.php.
 +
 +
The DPLcache will even survive editing of the page which contains the DPL statememnt as long as the DPL statement remains unaltered.
 +
 +
Details:
 +
 +
The cache is automatically registered under the page_id of your article. So there is no need to specify the page name or something similar here. Currently the cache is held in the file system (this may cahnge to the database in one of the next releases).
 +
 +
As the cache works on page_id level it will only affect the most recent version of each page. When viewing older revisions it may be useful to add ''&DPL_refresh=yes'' to the URL to make sure that the cache is rebuilt (if this is really desirable).
 +
 +
If your page uses ''scrolling'' you can provide an ''advanced cache'' which will take each result page (if it is viewed). In this case the ''name'' should look like this:
 +
<code>dplcache=offset/{%offset:0%}</code>
 +
This will create a separate cache entry for each result page. If one of these pages is purged (i.e. the cache is to be refreshed), all corresponding pages will be thrown away as well. See [[DPL Example 022]] to understand the details of this mechanism.
 +
 +
<u>The following principles apply to caching:</u>
 +
 +
* By default MW uses a ParserCache with an expiration of 24 hours. The expiration period can be influenced via $wgParserCacheExpireTime.
 +
* Once a page is in the ParserCache DPL will not be invoked any more as long as the cache is considered to be up-to-date. For this reason DPL normally DISABLES the MW ParserCache.
 +
* On really huge websites you may still want to use the MW ParserCache in addition to the DPL cache. You can do so via  setting 'allowcachedresults=true' as part of your DPL statement. Alternatively the administrator can configure DPL in a way that 'allowcachedresults=true' is the general default for DPL statements (set ExtDynamicPageList::$respectParserCache = true; after the require_once() for DPL).
 +
* If DPL is used together with an active ParserCache DPL can only check its own cache as soon as the MW ParserCache has expired, i.e. you cannot have a shorter period for the DPL cache than the MW ParserCache has.
 +
* You can always enforce the MWParserCache to be purged by adding &action=purge to the URL of a page. This will enforce a page refresh and DPL will be invoked. It can then find out if it still wants to rely on its DPL cache content or if it wants to re-execute the query against the database to produce the latest results and update its cache with that result.
 +
* Purging the ParserCache will silently be accepted for usres who are logged in; anonymous users will get a "do you really want ..." confirmation box.
 +
* Note that if your page contains more than one DPL statements, all of them need to set 'allowcachedresults=true' to avoid switching off the MW ParserCache. If, on the other hand, keeping the ParserCache is configured as DPL's default behaviour, the cache will be disabled as soon one of several DPL statements of a page explicitly switches it off via 'allowcachedresults=no'.
 +
* Regardless of the DPL configuration in your LocalSettings.php the &lt;DynamicPageList&gt; tag will always use the ParserCache (for reasons of compatibility with older versions of Dynamic Page List aka Extension:Intersection).
 +
* If a page is being served from the MW ParserCache there will be a respective comment in the HTML text - but the user will not get any notice. He may be surprosed however, that a page reflects 'outdated contents' although he  has just made a change which should have had an impact on the DPL result being displayed.
 +
* If you use the 'dplcache' command the user will see a little box under the DPL result which indiactes that the DPL cache has been used. It tells the user how old the content is and it can reduce the amount of annoyance caused by outdated results being taken from the cache. The note also offers a refresh button. If the MW ParserCache is active, however, this mechanism cannot work.
 +
* Using the ''FlaggedRevisions Extension'' together with DPL caching adds another level of complexity as that extension uses an additional cache ("StableParserCache").
 +
 +
=== dplcacheperiod ===
 +
 +
{{DPL parameter
 +
|name  = dplcacheperiod
 +
|purpose= define the expiration period for the dplcache
 +
}}
 +
 +
Syntax:
 +
 +
<code>dplcacheperiod= <i>number of seconds</i></code>
 +
 +
The default is 86400 seconds, i.e. one day.

Latest revision as of 07:23, 13 October 2009

Manual Other parameters

updaterules

updaterules define a set of rules which are executed to perform an update on selected articles (bulk update or template value editing)

Syntax:

updaterules=
    rule;
    ...
    rule;

Where rule is one of the following:

  • rules for batch update of articles
   replace   pattern;
      by        replacement;
   before    pattern;
      insert    text;
   after     pattern;
      insert    text;
  • rules for interactive update of articles
   template  template name;
   legend    legend article name;
   table     table format;
   editform  form parameters;
   action    form action;
   hidden    value;
   submit    submit button;
   commit    commit button;
   parameter parameter name;
      value      value;
      format     display format;
      tooltip    text;
      optional   value;
      afterparm  parameter name;
  • common rules
   summary   edit summary text;
   exec      value;

The first group of rules is intended for batch updates of articles. A DPL query can select a group of articles and perform updates like inserting a piece of text at a certain position or changing text portions based on regular expressions.

The second group of rules is intended for interactive form-based editing of template values.

The third group of rules is common to both other groups and controls the update process.

The updaterules feature is intended for wiki expert users only. It is recommended that articles usind this statement are 'protected':


Rules for batch update in detail:

replace pattern;

Defines a regular expression which matches text portions that shall be replaced. It is in the responsibility of the user to provide enclosing characters for the regexp; modifiers line 'U' or 'm' can be used.

by replacement;

Defines the replacement for the above pattern; back references like \1 can be used.

before pattern;

Defines locations where text will be inserted. The location(s) will be immediately before the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will be performed.

The regexp will implicitly be enclosed in slashes. Hence literal slash characters must be escaped by backslashes.

after pattern;

Defines locations where text will be inserted. The location(s) will be immediately after the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will be performed.

The regexp will implicitly be enclosed in slashes. Hence literal slash characters must be escaped by backslashes.

insert text;

Defines the text to be inserted.

A DPL statement may contain replacement, insertion before and after at the same time.

 replace /([a-z]+])-cat/;
 by      \1-dog;
 before foo;
 insert bar;
 after  foo;
 insert bar2;

Only one 'replace'-'by' sequence, one insertion 'before' and one insertion 'after' can be specified. 'replace' is always executed first, followed by 'insert before' and 'insert after', regardless of the sequence in which the rules appear in the DPL source ´text.

Rules for interactive update in detail:

template template name;

The name of the template; the prefix "Template:" must be given.



be inserted. The location(s) will be immediately before the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will be performed.

The regexp will implicitly be enclosed in slashes. Hence literal slash characters must be escaped by backslashes.


a regular expression

   after     pattern;
   insert    text;
   replace   pattern;
   by        replacement;



For safety reasons the update statements will only be performed if "exec yes" is specified. So, leaving this away, you can check what would happen if the update were to be executed.

Note that if "exec yes" is present the update will be performed each time the page is renderes which contains the DPL statement with the updaterules. So it is advisable to set "exec yes" only via a command line argument and not as part of the statioc article text. Thus you stay in control when the update happens. Typically one would use an URL parameter like DPL_arg1 for that purpose.

The size of the form fields will dapt to the size of the displayed content.



To make the use of the updaterules feature easier we provide a special user interface.

text is plain text; replacement is text which may contain references (like \1) to the matching pattern (provided that this pattern contains match groups).

deleterules

deleterules allow the mass deletion of wiki pages

deleterules=

    reason text;
    exec true;

This command is experimental at the moment.

This will delete the selected pages; If "exec true" is missing, nothing will happen.

goal

goal set the overall goal for DPL to either show pages (default) or categories these pages belong to

Syntax:

goal=pages | categories

Explanation:

Default is 'pages', which means that DPL produces a list of pages. And this is exactly what the name DPL promises.

If you set the goal parameter to 'categories' the list of pages will still be produced but you won´t see it. Instead it will be used to calculate a unique ordered list of all categories these pages belong to.

This allows you to ask a question like: Given all pages that are member of category X with a title matching "y%" and which use template "Z": to which categories do these pages belong?

One of the more useful applications would be question like: "To which categories do the pages belong which contain a reference to the current page?"

The output of "goal=categories" is technically a list of pages of type category. This means that you can use all DPL formatting options (mode=userformat, listseparators, columns etc.) and pseudo variables (%TITLE%, %PAGE%) to customise the layout of your report.

Technical Note:

Due to some limitations in MySQL it is currently not possible to restrict the intermediate result set of pages to a certain maximum (using the LIMIT clause). In addition the generated SQL code is not in all cases optimal (as its structure provides for complex selection criteria and therefore is unnecessarily complex in simple cases). So be careful and apply precise selection criteria.

allowcachedresults

allowcachedresults allow delivery of results based on cached database contents.

Syntax:

allowcachedresults=true | false | yes+warn

Explanation:

Default is FALSE, so normally DPL will disable the parser cache before it produces a result. Disabling the cache produces some extra server load but guarantees always correct results.

So, if you do not use this parameter you will always get a result which is based on the latest changes made on any articles. But in many cases you could have gotten the same result with using less server resources!

If you set 'allowcachedresults=true', the parser cache will be used. That means, your results might be a little bit outdated (usually one hour or so). But there are less resources used on the server side. You might want to experiment with that parameter and check the size of load reduction (i.e. gain in term of response time).

If you allow cached results you can still enforce DPL to produce a correct result via using "&action=purge" in the command line.

'yes+warn' will use the cache; in addition the result will contain a warning indicating that the result may be out-dated. This is achieved by including the template DPL Cache Warning into the result header. It is up to you to provide a useful text under that name, see e.g. Template:DPL Cache Warning.

reset

reset suppress references to pages, templates, images, categories in DPL output

Syntax:

reset=keyword,.., where keyword is one of:

  • categories
  • templates
  • images
  • links
  • all — a synonym for all of the above

The output of a DPL statement typically creates links to all pages which are part of the result set. The inclusion of contents from other pages via DPL (using 'include') normally has the consequence

  • that the page containing the DPL query becomes part of the categories of the transcluded page
  • that it shares ('adopts') their use of templates
  • that it shares their references to images
  • that it shares their references to other articles.

In some cases this may be useful. But in many cases this is not wanted. Especially when you use DPL to create a printable document which contains the full text of other articles you will probably not want to duplicate all links, template uses etc. of those articles.

The reset parameter will suppress all or some of the effects described above.

There are some subtle differences here depending on the mode in which you use DPL. These differences affect the question how links, and categories etc. are treated which are direct part of the document containing the DPL query. Example:

 [[Category:Q Cat]] linking to [[Q Link]] and showing [[Image:Q Image]] and using {{Q Template}}
 ... DPL query which includes contents from other articles.
     assuming that this contents contains links and images, 
              that it uses templates and thatthe articles are part of one or more categories
     RESET statement at the end of the DPL query with one or more of 'categories,templates,images,links'
 ...

In parser extension mode (DPL tag like <DPL>):

reset=categories
will ignore categories of included contents but keep 'own' categories like 'Q Cat'.
reset=images
will throw away references to images contained in included contents but keep 'own' images like 'Q Image'.
reset=templates
will ignore templates used in included contents but keep 'own' template usage ('Q Template').
reset=links
will throw away all references to other pages, i.e. links contained in included contents and links like 'Q Link' will be ignored. This means that all links can be used in the normal "FORWARD" way, but no "BACKLINKS" are available for them.

If you want to avoid the above described effect of reset on your 'own' links you can use eliminate. But you should know that eliminate is rather expensive in terms of computer power as it does a second parse for all included contents.


In parser fuction mode ({{#DPL:....}}):

reset=categories
will ignore all categories
reset=images
will throw away all references to images
reset=templates
will ignore all template invocations
reset=links
will throw away all references to other pages

As you see, using reset in parser function mode will clear everything regardless whether it comes from included contents or whether it is direct part of the document containing the DPL query.

If you want to avoid the above described effect of reset, you can use eliminate. But you should know that eliminate is rather expensive in terms of computing power as it does a second parse for all included contents. The extra parser step is conducted as soon as you specify eliminate. In terms of extra processing needed it does not make a difference whether you specify one or more arguments for the 'eliminate' command.

If you have more than one DPL query in a document the effects will depend on the exact mode (parser extension or parser function mode), on the sequence of the statements and on the presence of 'reset' or 'eliminate' statements in each of the queries and on their individual arguments. As this is a very rare case we only give a simple rule of thumb here: Once you have used 'reset' in parser function mode or 'reset=links' in parser extension mode the effect of these statements will dominate the rest.


fixcategory

fixcategory assign the article containing a DPL statement to a category although reset was used.

Syntax: fixcategory=category name

Use multiple commands to assign the article to more than one category.

If you use reset=all or reset=categories the article containing your DPL statement will not be recorded in the mediawiki link database. This may be quite useful if your article transcludes content from other pages. Without the reset command your article would appear in a category if you included a text portion containing an assignment to that category.

As a side effect of using reset=all your article will not appear in a category even if you literally assign it to one. The fixcategory allows you to make a category assignment which is not blocked by the reset command.

eliminate

eliminate suppress references to pages, templates, images, categories in DPL output

Syntax:

eliminate=keyword,..

Where keyword is one of:

  • categories
  • templates
  • images
  • links
  • all — a synonym for all of the above

The output of a DPL statement typically creates links to all pages which are part of the result set. The inclusion of contents from other pages via DPL (using include) normally has these consequences:

  • the page containing the DPL query becomes part of the categories of the transcluded page
  • shares ('adopts') their use of templates
  • shares their references to images
  • shares their references to other articles

In some cases this may be useful. But in many cases this is not wanted. Especially when you use DPL to create a printable document which contains the full text of other articles you will probably not want to duplicate all links, template uses etc. of those articles.

The eliminate parameter will suppress all or some of the effects described above.

For further explanation see reset.

Please note that the use of eliminate needs a considerable amount of extra computing power as it performs a second parser step for each included document.

debug

debug Sets debugging level.

Syntax:

debug=n, where n is one of:

  • 0 — silent mode, shows nothing
  • 1 — quiet mode, shows (fatal) errors
  • 2 — default mode, like 1 + shows warnings; — (default)
  • 3 — verbose mode, like 2 + shows SQL query.
  • 4 — for internal use only
  • 5 — show Wiki text output from DPL instead of parsed wiki text
  • 6 — show SQL query but DO NOT EXECUTE the query.

If you use debug param but not in first position in the DPL element, the new debug settings are not applied before all previous parameters have been parsed and checked. This will generate a warning for debug=2 and above.

Example:

<DPL>
  namespace=Media
  debug=0
  namespace=Special
</DPL>

This list will output the error for the first namespace: Media is not a valid namespace value (pseudo-namespace). Assuming you haven't changed the default debug value (2), you will also get a warning: debug=1 is not input first (before namespace=Media). So it did not apply to namespace=Media but only to what's after. Indeed, you won't get the warning for the second namespace (Special) since debug=0 changed debug settings to silent mode.

DPL debug messages are translatable in DynamicPageList2.i18n.php. See also #Internationalization.

'debug=1' will suppress warning messages (e.g. if the result set of a DPL query is empty). As an alternative, you can use the suppresserrors statement.


execandexit

execandexit process the command given as an argument and then exit immediately.

Syntax:

execandexit=wiki text
or
execandexit=geturlargs

If no wiki text is given the command will be ignored. Otherwise DPL will output the wiki text and exit immediately. Note that the wiki text may be a parser function call which evaluates to an empty string.

The special word geturlargs can be used as a wiki text to transform URL arguments into variables which can then be accessed via #var (if the Variables extension is installed) or via #dplvar.

Purpose:

Using this command you can prevent DPL from executing a database query; this may be useful if a necessary parameter was not given by the user. Note that an #if function call would NOT help in that case because #if evaluates its complete content before taking the "if" or the "else" path. So, emebdding a DPL call within a #if is much less efficient than using the execandexit function.

A typical use would look like this (note the double pipe symbols within the #if. Calling the following page with &cat=Country would list countries, omitting the &cat parameter would trigger the error text mnessage (without DPL going to the database):

{{#dpl:execandexit=geturlargs}}
{{#dpl: 
 | execandexit     = {{#if:{{#dplvar:cat}}||please specify a category via &cat= in the URL!}}
 | resultsheader   = pages in category {{#dplvar:cat}}:\n
 | noresultsheader = there are no pages in category {{#dplvar:cat}}.\n
 | count           = 5
 | category        = {{#dplvar:cat}}
}}

See also: Template:Extension DPL scroll and DPL Example 020 and Scrolling

Note execandexit acts like a short-circuit evaluation. This means, for example, that successive statements to influence caching behaviour (like allowcachedresults) will not be interpreted.

dplcache

dplcache put the result of a DPL query in a special cache from where it is served until the cache expires

Syntax:

dplcache=name

name must be a symbol which is unique for the DPL statement WITHIN your page. As you will in most cases have only one DPL statement in your page, a simple symbol like '1' will be o.k.

Purpose:

Save processing time and avoid unnecessary resource consumption. You can decide how long the result of a DPL query shall be considered to be reasonably 'valid'. This may be longer or shorter than the ParserCacheExpiration time which you have configured in your LocalSettings.php.

The DPLcache will even survive editing of the page which contains the DPL statememnt as long as the DPL statement remains unaltered.

Details:

The cache is automatically registered under the page_id of your article. So there is no need to specify the page name or something similar here. Currently the cache is held in the file system (this may cahnge to the database in one of the next releases).

As the cache works on page_id level it will only affect the most recent version of each page. When viewing older revisions it may be useful to add &DPL_refresh=yes to the URL to make sure that the cache is rebuilt (if this is really desirable).

If your page uses scrolling you can provide an advanced cache which will take each result page (if it is viewed). In this case the name should look like this: dplcache=offset/{%offset:0%} This will create a separate cache entry for each result page. If one of these pages is purged (i.e. the cache is to be refreshed), all corresponding pages will be thrown away as well. See DPL Example 022 to understand the details of this mechanism.

The following principles apply to caching:

  • By default MW uses a ParserCache with an expiration of 24 hours. The expiration period can be influenced via $wgParserCacheExpireTime.
  • Once a page is in the ParserCache DPL will not be invoked any more as long as the cache is considered to be up-to-date. For this reason DPL normally DISABLES the MW ParserCache.
  • On really huge websites you may still want to use the MW ParserCache in addition to the DPL cache. You can do so via setting 'allowcachedresults=true' as part of your DPL statement. Alternatively the administrator can configure DPL in a way that 'allowcachedresults=true' is the general default for DPL statements (set ExtDynamicPageList::$respectParserCache = true; after the require_once() for DPL).
  • If DPL is used together with an active ParserCache DPL can only check its own cache as soon as the MW ParserCache has expired, i.e. you cannot have a shorter period for the DPL cache than the MW ParserCache has.
  • You can always enforce the MWParserCache to be purged by adding &action=purge to the URL of a page. This will enforce a page refresh and DPL will be invoked. It can then find out if it still wants to rely on its DPL cache content or if it wants to re-execute the query against the database to produce the latest results and update its cache with that result.
  • Purging the ParserCache will silently be accepted for usres who are logged in; anonymous users will get a "do you really want ..." confirmation box.
  • Note that if your page contains more than one DPL statements, all of them need to set 'allowcachedresults=true' to avoid switching off the MW ParserCache. If, on the other hand, keeping the ParserCache is configured as DPL's default behaviour, the cache will be disabled as soon one of several DPL statements of a page explicitly switches it off via 'allowcachedresults=no'.
  • Regardless of the DPL configuration in your LocalSettings.php the <DynamicPageList> tag will always use the ParserCache (for reasons of compatibility with older versions of Dynamic Page List aka Extension:Intersection).
  • If a page is being served from the MW ParserCache there will be a respective comment in the HTML text - but the user will not get any notice. He may be surprosed however, that a page reflects 'outdated contents' although he has just made a change which should have had an impact on the DPL result being displayed.
  • If you use the 'dplcache' command the user will see a little box under the DPL result which indiactes that the DPL cache has been used. It tells the user how old the content is and it can reduce the amount of annoyance caused by outdated results being taken from the cache. The note also offers a refresh button. If the MW ParserCache is active, however, this mechanism cannot work.
  • Using the FlaggedRevisions Extension together with DPL caching adds another level of complexity as that extension uses an additional cache ("StableParserCache").

dplcacheperiod

dplcacheperiod define the expiration period for the dplcache

Syntax:

dplcacheperiod= number of seconds

The default is 86400 seconds, i.e. one day.