Other parameters: Difference between revisions

Add more examples
imported>FrozenPlum
(Fixes and edits)
imported>FrozenPlum
(Add more examples)
 
(3 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> – Silent mode, shows nothing.
* <code>''1''</code> – Quiet mode, shows (fatal) errors.
* <code>''2''</code> – Default mode, like 1 + shows warnings; – '''(default)'''.
* <code>''3''</code> – Verbose mode, like 2.
* <code>''4''</code> – Dump raw SQL Query; only if ''$wgDebugDumpSql'' is set to true.
* <code>''5''</code> – Show wiki text output from DPL3 instead of parsed wiki text.
 
 
{{note|'''Note:''' If the debug parameter is used, but '''not''' used in the first position inof the DPL3 elementstatement, the new debug settings are not applied before all previous parameters have been parsed and checked.''' This generates 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.
 
DPL3 debug messages are translatable in ''DynamicPageList2.i18n.php''.
 
'''ExampleNotes:'''
<code>debug=1</code> suppresses warning messages (e.g., if the result set of a DPL3 query is empty). As an alternative, the <code>{{DPL|suppresserrors}}=</code> statement can be used.
* DPL3 debug messages are translatable in ''DynamicPageList2.i18n.php''.
* <code>debug=''1''</code> suppresses warning messages (e.g., if the result set of a DPL3 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> – ('''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. Cache period is handled by the <code>{{DPL|cacheperiod}}</code> 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= Defines the expiration period for the DPL3 cache.
}}
 
Line 67 ⟶ 64:
'''Syntax:'''
 
<code>cacheperiod=''number of seconds''</code> – ('''default''' is 3600, meaning 1 hour).
 
 
Line 73 ⟶ 70:
{{DPL Parameter
|name = goal
|purpose= Set the goal for DPL3 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> – ('''default''', need not be set).
* <code>''categories''</code>.
 
 
Line 113 ⟶ 110:
'''Syntax:'''
 
<code>eliminate=''keyword,..''</code> where ''{{tt|keyword''}} is one of:
* <code>''categories''</code>
* <code>''templates''</code>
Line 122 ⟶ 119:
 
The output of a DPL3 statement typically creates links to all pages which are part of the result set. The inclusion of contents from other pages via DPL3 (using <code>{{DPL|include}}</code>) normally has these consequences:
* The page containing the DPL3 query becomes part of the categories of the transcluded page.
* It shares ('adopts') their use of templates.
* It shares their references to images.
Line 146 ⟶ 143:
'''Syntax:'''
 
<code>reset=''keyword,..''</code>, where ''{{tt|keyword''}} is one of:
* <code>''categories''</code>
* <code>''templates''</code>
Line 178 ⟶ 175:
 
'''In parser extension mode''' (tag like <code><nowiki><dpl></nowiki></code>):
* <code>reset=''categories''</code> – Ignores categories of included contents but keeps 'own' categories like 'Q Cat'.
* <code>reset=''images''</code> – Throws away references to images contained in included contents but keeps 'own' images like 'Q Image'.
* <code>reset=''templates''</code> – Ignores templates used in included contents but keeps 'own' template usage ('Q Template').
* <code>reset=''links''</code> – Throws away all references to other pages, i.e., links contained in included contents and links like 'Q Link' are ignored. This means all links can be used in the normal "FORWARD" way, but no "BACKLINKS" are available for them.
 
 
Line 188 ⟶ 185:
 
''' In parser function mode''' (<code><nowiki>{{#dpl:....}}</nowiki></code>):
* <code>reset=''categories''</code> – Ignores all categories.<br>
* <code>reset=''images''</code> – Throws away all references to images.
* <code>reset=''templates''</code> – Ignores all template invocations.
* <code>reset=''links''</code> – Throws away all references to other pages.
 
 
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 MediaWiki 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 does not appear in a category, even if one is literally assigned to it.
<code>fixcategory</code> allows a category assignment to be made which is not blocked by the <code>reset</code> command.
 
Line 237 ⟶ 234:
If no wiki text is given, the command is ignored. Otherwise, DPL3 outputs the wiki text and exits 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}}
{{ViewTest|Examples|Parameter: execandexit (example 1)}}
 
'''Result:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 1)|Result}}
 
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.
Line 243 ⟶ 245:
 
 
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 2)|Example}}
A typical use would look like this (note the double pipe symbols within the #if.
{{ViewTest|Examples|Parameter: execandexit (example 2)}}
Calling the following page with &DPL_cat=Country would list countries, omitting the <code>&cat</code> 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>
 
 
'''Result:'''<!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 2)|Result}}
'''See also:''' [[Template:Extension DPL scroll]] and {{DPL|scrolling}}.
 
 
'''See also:''' [[Template:Extension DPLDPL3 scroll]] and {{DPL|scrolling}}.
'''Note:''' <code>execandexit</code> acts like a short-circuit evaluation. This means, for example, that successive statements to influence caching behavior (like <code>{{DPL|allowcachedresults}}</code>) are not interpreted.
 
 
{{note|'''Note:''' <code>execandexit</code> acts like a short-circuit evaluation. This means, for example, that successive statements to influence caching behavior (like <code>{{DPL|allowcachedresults}}</code>) are not interpreted.}}
 
 
Line 363 ⟶ 358:
 
A regular expression:
 
<pre>
after ''pattern'';
insert ''text'';
replace ''pattern'';
by ''replacement'';
 
</pre>
 
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.
Anonymous user