Other parameters: Difference between revisions

Add more examples
imported>FrozenPlum
(Add example)
imported>FrozenPlum
(Add more examples)
 
(2 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.
Line 21:
 
 
{{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/ModuleParameter: debug (example 1)|Example}}
{{ViewTest|Examples|ModuleParameter: debug (example 1)}}
 
'''Result:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: debug (example 1)|Result}}
 
 
'''Notes:'''
* 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 42 ⟶ 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 53 ⟶ 58:
{{DPL Parameter
|name = cacheperiod
|purpose= Defines the expiration period for the DPL3 cache.
}}
 
Line 65 ⟶ 70:
{{DPL Parameter
|name = goal
|purpose= Set the goal for DPL3 to either show '''pages''' (default) or '''categories''' these pages belong to.
}}
 
Line 71 ⟶ 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 105 ⟶ 110:
'''Syntax:'''
 
<code>eliminate=''keyword,..''</code> where ''{{tt|keyword''}} is one of:
* <code>''categories''</code>
* <code>''templates''</code>
Line 114 ⟶ 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 138 ⟶ 143:
'''Syntax:'''
 
<code>reset=''keyword,..''</code>, where ''{{tt|keyword''}} is one of:
* <code>''categories''</code>
* <code>''templates''</code>
Line 170 ⟶ 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 180 ⟶ 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 207 ⟶ 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 229 ⟶ 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 235 ⟶ 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 355 ⟶ 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