Other parameters: Difference between revisions

Add more examples
imported>FrozenPlum
m (Fix a couple more things I couldn't see on first edit)
imported>FrozenPlum
(Add more examples)
 
(4 intermediate revisions by the same user not shown)
Line 12:
'''Syntax:'''
 
<code>debug=<i>n</i></code>, where ''{{tt|n''}} is one of:
* <code>''0''</code> &mdash; Silent mode, shows nothing.
* <code>''1''</code> &mdash; Quiet mode, shows (fatal) errors.
* <code>''2''</code> &mdash; Default mode, like 1 + shows warnings; &mdash; '''(default)'''.
* <code>''3''</code> &mdash; Verbose mode, like 2.
* <code>''4''</code> &mdash; Dump raw SQL Query; only if ''$wgDebugDumpSql'' is set to true.
* <code>''5''</code> &mdash; Show wiki text output from DPLDPL3 instead of parsed wiki text.
 
 
{{note|'''Note:''' If the debug paramparameter is used, but '''not''' used in the first position inof the DPLDPL3 elementstatement, the new debug settings are not applied before all previous parameters have been parsed and checked.''' This will generategenerates a warning for <code>debug{{=}}2</code> and above.}}
 
 
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: debug (example 1)|Example}}
'''Example:'''
{{ViewTest|Examples|Parameter: debug (example 1)}}
 
'''Result:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: debug (example 1)|Result}}
<pre><nowiki>
{{#dpl:
| namespace = Media
| debug = 0
| namespace = Special
}}
</nowiki></pre>
 
This outputs the error for the first namespace: ''Media'' is not a valid namespace value (pseudo-namespace). Assuming the default debug value (2) hasn't been changed, a warning is also displayed: <code>debug=1</code> is not input first (before <code>namespace=Media</code>). So, it did not apply to <code>namespace=Media</code> but only to what's after. Indeed, the warning for the second namespace (''Special'') is not given, since <code>debug=0</code> changed debug settings to silent mode.
 
DPL debug messages are translatable in ''DynamicPageList2.i18n.php''.
 
'''ExampleNotes:'''
<code>debug=1</code> will suppress warning messages (e.g., if the result set of a DPL query is empty). As an alternative, the <code>{{DPL|suppresserrors}}=</code> statement can be used.
DPL* DPL3 debug messages are translatable in ''DynamicPageList2.i18n.php''.
* <code>debug=''1''</code> will suppresssuppresses warning messages (e.g., if the result set of a DPLDPL3 query is empty). As an alternative, the <code>{{DPL|suppresserrors}}=</code> statement can be used.
 
 
Line 50 ⟶ 44:
'''Syntax:'''
 
<code>allowcachedresults=''value''</code> where ''{{tt|value''}} is one of:
* <code>''true''</code> &mdash; ('''default''', need not be set).
* <code>''false''</code> – prevent caching.
 
 
'''Notes:'''
* All queries are cached by default '''to reduce server load''', as generally articles do not change often enough to require updating every page load. If immediate updates are required every page load, then set this parameter to false. The cache period is handled by the [[#cacheperiod]] parameter.
* If immediate updates are required every page load, such as for displaying {{DPL|scroll}} navigation via {{DPL|URL parameters}}, then set this parameter to false.
* Cache period is handled by the <code>{{DPL|cacheperiod}}</code> parameter.
 
 
Line 61 ⟶ 58:
{{DPL Parameter
|name = cacheperiod
|purpose= DefineDefines the expiration period for the dplcacheDPL3 cache.
}}
 
Line 67 ⟶ 64:
'''Syntax:'''
 
<code>cacheperiod=''number of seconds''</code> &mdash; ('''default''' is 3600, meaning 1 hour).
 
 
Line 73 ⟶ 70:
{{DPL Parameter
|name = goal
|purpose= Set the overall goal for DPLDPL3 to either show '''pages''' (default) or '''categories''' these pages belong to.
}}
 
Line 79 ⟶ 76:
'''Syntax:'''
 
<code>goal=''goaltype''</code> where ''{{tt|goaltype''}} can be one of:
* <code>''pages''</code> &mdash; ('''default''', need not be set).
* <code>''categories''</code>.
 
 
DPLDPL3 produces a list of pages by default, and this is precisely what the name DPLDPL3 promises.
 
 
If the goal parameter is set to 'categories' the list of pages is still be produced, but is not seen. Instead, it is be used to '''calculate a unique ordered list of all categories these pages belong to'''.
 
 
This allows the asking of question like: Given all pages that are a member of category ''X'' with a title matching ''"y%"'' and which use template ''"Z"'': to which categories do these pages belong?
 
 
Line 96 ⟶ 93:
 
 
The output of "<code>goal=categories"</code> is technically a ''list of pages of type category''. This means that all DPLDPL3 formatting options can be used (<code>mode=userformat</code>, <code>listseparators</code>, <code>columns</code> etc.) and pseudo variables (<code>%TITLE%</code>, <code>%PAGE%</code>) to customize the layout of the report.
 
 
Line 107 ⟶ 104:
{{DPL Parameter
|name = eliminate
|purpose= Suppress references to pages, templates, images, categories in DPLDPL3 output
}}
 
Line 113 ⟶ 110:
'''Syntax:'''
 
<code>eliminate=''keyword,..''</code> where ''{{tt|keyword''}} is one of:
* <code>''categories''</code>
* <code>''templates''</code>
* <code>''images''</code>
* <code>''links''</code>
* <code>''all''</code> &mdash; aA synonym for all of the above.
 
 
The output of a DPLDPL3 statement typically creates links to all pages which are part of the result set. The inclusion of contents from other pages via DPLDPL3 (using <code>{{DPL|include}}</code>) normally has these consequences:
* theThe page containing the DPLDPL3 query becomes part of the categories of the transcluded page.
* It shares ('adopts') their use of templates.
* It shares their references to images.
* It shares their references to other articles.
 
 
In some cases, this may be useful. But in many cases, this is not wanted. Especially when DPLDPL3 is used to create a printable document which contains the full text of other articles, duplicating all links, template uses etc., of those articles is probably undesired.
 
The <code>eliminate</code> parameter will suppresssuppresses all or some of the effects described above.
 
For further explanation, see <code>{{DPL|reset}}</code>.
 
'''Note:''' The use of <code>eliminate</code> needs a considerable amount of extra computing power as it performs a second parser step for each included document.
Line 140 ⟶ 137:
{{DPL Parameter
|name = reset
|purpose= Suppress references to pages, templates, images, categories in DPLDPL3 output
}}
 
Line 146 ⟶ 143:
'''Syntax:'''
 
<code>reset=''keyword,..''</code>, where ''{{tt|keyword''}} is one of:
* <code>''categories''</code>
* <code>''templates''</code>
* <code>''images''</code>
* <code>''links''</code>
* <code>''all''</code> &mdash; aA synonym for all of the above.
 
 
The output of a DPLDPL3 statement typically creates links to all pages which are part of the result set. The inclusion of contents from other pages via DPLDPL3 (using '<code>include'</code>) normally has the consequenceconsequences:
* that theThe page containing the DPLDPL3 query becomes part of the categories of the transcluded page.
* that itIt shares ('adopts') their use of templates
* that itIt shares their references to images
* that itIt shares their references to other articles.
 
 
In some cases, this may be useful. But in many cases, this is not wanted. Especially when DPLDPL3 is used to create a printable document which contains the full text of other articles, duplicateingduplicating all links, template uses etc., of those articles is probably undesired.
 
The <code>reset</code> parameter will suppresssuppresses all or some of the effects described above.
 
There are some subtle differences here depending on the mode in which DPL3 is used. These differences affect the question of how links, and categories etc., are treated which are direct part of the document containing the DPL3 query.
Line 177 ⟶ 174:
 
 
<u>'''In parser extension mode (DPL3 ''' (tag''' like &lt;DPL&gt;):<code><nowiki><dpl></unowiki></code>):
;* <code>reset=''categories:''</code> will ignoreIgnores categories of included contents but keepkeeps 'own' categories like 'Q Cat'.
;* <code>reset=''images:''</code> will throwThrows away references to images contained in included contents but keepkeeps 'own' images like 'Q Image'.
;* <code>reset=''templates:''</code> will ignoreIgnores templates used in included contents but keepkeeps 'own' template usage ('Q Template').
;* <code>reset=''links:''</code> will throwThrows away all references to other pages, i.e., links contained in included contents and links like 'Q Link' will beare ignored. This means that all links can be used in the normal "FORWARD" way, but no "BACKLINKS" are available for them.
 
 
To avoid the above described effect of <code>reset</code> on one's 'own' links, <code>{{DPL|eliminate}}</code> can be used. However, it is important to note that ''eliminate'' is rather expensive in terms of computer power, as it does a second parse for all included contents.
 
 
<u>''' In parser function mode (''' (<code><nowiki>{{#DPLdpl:....}}</nowiki>'''):</ucode>):
;* <code>reset=''categories:''</code> will ignoreIgnores all categories.<br>
;* <code>reset=''images:''</code> will throwThrows away all references to images .
;* <code>reset=''templates:''</code> will ignoreIgnores all template invocations.
;* <code>reset=''links:''</code> will throwThrows away all references to other pages.
 
 
Using <code>reset</code> in parser function mode clears everything, regardless of whether it comes from included contents or whether it is direct part of the document containing the DPL3 query.
 
To avoid the above described effect of <code>reset</code>, <code>{{DPL|eliminate}}</code> can be used. However, ''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 <code>''eliminate</code>'' is specified. In terms of extra processing needed, it does not make a difference whether one or more arguments are specified for the ''eliminate'' command.
 
If there is '''more than one DPL3 query''' in a page, the effects 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, only a simple rule of thumb is given here: Once 'reset' is used in parser function mode or '<code>reset=links'</code> in parser extension mode, the effect of these statements will dominatedominates the rest.
 
 
Line 215 ⟶ 212:
Use multiple commands to assign the article to more than one category.
 
If <code>reset=''all''</code> or <code>reset=''categories''</code> are used, the article containing the DPL3 statement is not be recorded in the mediawikiMediaWiki link database. This may be quite useful if an article transcludes content from other pages. Without the <code>{{DPL|reset}}</code> command, the article would appear in a category if a text portion containing an assignment to that category was used.
 
As a side effect of using <code>reset=''all''</code>, the article willdoes not appear in a category, even if one is literally assigned to it.
The <code>fixcategory</code> allows a category assignment to be made which is not blocked by the {{DPL|<code>reset}}</code> command.
 
 
Line 235 ⟶ 232:
 
 
If no wiki text is given, the command will beis ignored. Otherwise, DPL3 will outputoutputs the wiki text and exitexits immediately.
Note that the wiki text may be a parser function call which evaluates to an empty string.
 
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 1)|Example}}
The special word ''geturlargs'' can be used as a wiki text to transform URL arguments starting with <code>DPL_</code> into variables, which can then be accessed via #var (if the Variables extension is installed) or via #dplvar.
{{ViewTest|Examples|Parameter: execandexit (example 1)}}
 
'''Result:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 1)|Result}}
Using this command, DPL3 can be prevented 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 DPL3 call within a #if is much less efficient than using the ''execandexit'' function.
 
The special word ''geturlargs'' can be used as a wiki text to transform URL arguments starting with <code>DPL_</code> into variables, which can then be accessed via #var (if the [[mw:Extension:Variables|Variables]] extension is installed) or via #dplvar.
 
Using this command, DPL3 can be prevented from executing a database query; this may be useful if athe necessaryuser parameter wasdid not givengive bya thenecessary userparameter. Note that an ''<code><nowiki>{{#if'':}}</nowiki></code> ([[mw:Help:Extension:ParserFunctions|Parser Functions]] extension) function call would NOT help in that case because ''<code>#if''</code> evaluates its complete content before taking the "if" or the "else" path. So, emebddingembedding a DPL3 call within aan <code>#if</code> 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 &DPL_cat=Country would list countries, omitting the &cat parameter would trigger the error text message (without DPL3 going to the database):
<pre><nowiki>
{{#dpl:execandexit=geturlargs}}
{{#dpl:
| execandexit = {{#if:{{#dplvar:DPL_cat}}||please specify a category via &DPL_cat= in the URL!}}
| resultsheader = pages in category {{#dplvar:DPL_cat}}:\n
| noresultsheader = there are no pages in category {{#dplvar:DPL_cat}}.\n
| count = 5
| category = {{#dplvar:DPL_cat}}
}}
</nowiki></pre>
 
 
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 2)|Example}}
''See also:''' [[Template:Extension DPL scroll]] and {{DPL|scrolling}}
{{ViewTest|Examples|Parameter: execandexit (example 2)}}
 
 
'''Result:'''<!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 2)|Result}}
'''Note:''' <code>execandexit</code> acts like a short-circuit evaluation. This means, for example, that successive statements to influence caching behaviour (like {{DPL|allowcachedresults}}) will not be interpreted.
 
 
'''See also:''' [[Template:Extension DPLDPL3 scroll]] and {{DPL|scrolling}}.
 
 
{{note|'''Note:''' <code>execandexit</code> acts like a short-circuit evaluation. This means, for example, that successive statements to influence caching behaviourbehavior (like <code>{{DPL|allowcachedresults}}</code>) willare not be interpreted.}}
 
 
Line 278 ⟶ 273:
''rule'';
 
Where ''rule'' is one of the following:
# '''Rules for batch update of articles'''
#* A DPL3 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.
Line 327 ⟶ 322:
 
====before ''pattern'';====
Defines locations where text will be inserted. The location(s) will beare immediately before the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will beare performed.
 
The regexp will implicitly be enclosed in slashes. Hence, literal slash characters must be escaped by backslashes.
Line 333 ⟶ 328:
 
====after ''pattern'';====
Defines locations where text will be inserted. The location(s) will beare immediately after the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will beare performed.
 
The regexp will implicitly be enclosed in slashes. Hence, literal slash characters must be escaped by backslashes.
Line 341 ⟶ 336:
Defines the text to be inserted.
 
A DPL3 statement may contain replacement, insertion, before, and after at the same time.
<pre>
replace /([a-z]+])-cat/;
by \1-dog;
Line 348 ⟶ 344:
after foo;
insert bar2;
</pre>
 
Only one '<code>replace'</code> -' <code>by'</code> sequence, one insertion '<code>before'</code> and one insertion '<code>after'</code> can be specified. '<code>replace'</code> is always executed first, followed by '<code>insert before'</code> and '<code>insert after'</code>, regardless of the sequence in which the rules appear in the DPL3 source ´text.
 
 
Line 356 ⟶ 353:
The name of the template; the prefix "Template:" must be given.
 
be inserted. The location(s) will beare immediately before the match(es) of the pattern. If a pattern matches multiple times, multiple inserts will beare performed.
 
The regexp will implicitly be enclosed in slashes. Hence, literal slash characters must be escaped by backslashes.
 
aA regular expression:
 
after ''pattern'';
insert ''text'';
replace ''pattern'';
by ''replacement'';
 
 
For safety reasons, the update statements are only performed if "exec yes" is specified. So, leaving this away, what would happen if the update were to be executed can be checked.
 
Note that if "exec yes" is present, the update is performed each time the page is rendered which contains the DPL3 statement with the <code>updaterules</code>. So, it is advisable to set "exec yes" only via a command line argument and not as part of the static article text. Thus, staying in control when the update happens. Typically, one would use a URL parameter like ''DPL_arg1'' for that purpose.
 
The size of the form fields will daptadapts to the size of the displayed content.
 
<!--To make the use of the <code>updaterules</code> feature easier, we provide a [[Template:Bulk Update|special user interface]].
Line 390 ⟶ 389:
This command is experimental at the moment.
 
This will deletedeletes the selected pages; If "exec true" is missing, nothing will happenhappens.
 
[[Category:Primary Module|05]]
Anonymous user