Anonymous user
Other parameters: Difference between revisions
Add more examples
imported>FrozenPlum (Put in an order that actually makes sense, rather than least exotic first that's rarely enabled on any wiki) |
imported>FrozenPlum (Add more examples) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1:
{{DPL manual|section=Parameters|subsection=Other parameters}}
{{tocright}}
Line 10 ⟶ 9:
}}
'''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 '''not''' used in the first position of the DPL3 statement, 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}}
{{ViewTest|Examples|Parameter: 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 45 ⟶ 41:
}}
'''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, 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 58:
{{DPL Parameter
|name = cacheperiod
|purpose=
}}
'''Syntax:'''
Line 71 ⟶ 70:
{{DPL Parameter
|name = goal
|purpose=
}}
'''Syntax:'''
<code>goal=''goaltype''</code> where {{tt|goaltype}} can be one of:
* <code>''pages''</code> – ('''default''', need not be set).
* <code>''categories''</code>.
DPL3 produces a list of pages by default, and this is precisely what the name DPL3 promises.
If the goal parameter is set to 'categories' the list of pages is still be produced, but is not seen. Instead, it is 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?
One of the more useful applications would be a question like: "To which categories do the pages belong which contain a reference to the current page?"
The output of <code>goal=categories</code> is technically a ''list of pages of type category''. This means that all DPL3 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.
'''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.
Line 98 ⟶ 104:
{{DPL Parameter
|name = eliminate
|purpose=
}}
'''Syntax:'''
* <code>''categories''</code>
* <code>''templates''</code>
* <code>''images''</code>
* <code>''links''</code>
* <code>''all''</code> – A synonym for all of the above.
The output of a
*
* 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 DPL3 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 suppresses 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 131 ⟶ 137:
{{DPL Parameter
|name = reset
|purpose=
}}
'''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> – A synonym for all of the above.
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>include</code>) normally has the 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
* It shares their references to other articles.
In some cases, this may be useful. But in many cases, this is not wanted. Especially when
The <code>reset</code> parameter
There are some subtle differences here depending on the mode in which
Example:
<pre><nowiki>
[[Category:Q Cat]] linking to [[Q Link]] and showing [[Image:Q Image]] and using {{Q Template}}
...
assuming that this contents contains links and images,
that it uses templates and
RESET statement at the end of the
...
</nowiki></pre>
'''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.
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.
''' 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.
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 ''eliminate'' 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 dominates the rest.
Line 189 ⟶ 201:
{{DPL Parameter
|name = fixcategory
|purpose=
}}
'''Syntax:'''
<code>fixcategory=''category name''</code>
Use multiple commands to assign the article to more than one category.
If
As a side effect of using <code>reset=''all''</code>,
Line 206 ⟶ 221:
{{DPL Parameter
|name = execandexit
|purpose=
}}
'''Syntax:'''
<code>execandexit=''wiki text''</code>
<br>or<br>
<code>execandexit=
If no wiki text is given, the command
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.
Using this command, DPL3 can be prevented from executing a database query; this may be useful if the user did not give a necessary parameter. 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, embedding a DPL3 call within an <code>#if</code> is much less efficient than using the ''execandexit'' function.
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 2)|Example}}
{{ViewTest|Examples|Parameter: execandexit (example 2)}}
'''Result:'''<!-- transclude example from subpage-->{{#lsth:Examples/Parameter: execandexit (example 2)|Result}}
'''See also:''' [[Template:DPL3 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 behavior (like <code>{{DPL|allowcachedresults}}</code>) are not interpreted.}}
Line 245 ⟶ 261:
{{DPL Parameter
|name = updaterules
|purpose=
{{note|'''Important:''' The <code>updaterules</code> feature is intended for wiki expert users only. It is recommended that articles using this statement are '[[mw:Help:Protecting and unprotecting pages|protected]]'.|error}}
}}
'''Syntax:'''
updaterules=
...
Where ''rule'' is one of the following:
# '''Rules for batch update of articles'''
#* A
replace ''pattern'';
Line 306 ⟶ 322:
====before ''pattern'';====
Defines locations where text will be inserted. The location(s)
The regexp will implicitly be enclosed in slashes. Hence, literal slash characters must be escaped by backslashes.
Line 312 ⟶ 328:
====after ''pattern'';====
Defines locations where text will be inserted. The location(s)
The regexp will implicitly be enclosed in slashes. Hence, literal slash characters must be escaped by backslashes.
Line 320 ⟶ 336:
Defines the text to be inserted.
A
<pre>
replace /([a-z]+])-cat/;
by \1-dog;
Line 327 ⟶ 344:
after foo;
insert bar2;
</pre>
Only one
Line 335 ⟶ 353:
The name of the template; the prefix "Template:" must be given.
The regexp will implicitly be enclosed in slashes. Hence, literal slash characters must be escaped by backslashes.
after ''pattern'';
insert ''text'';
Line 345 ⟶ 364:
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
<!--To make the use of the <code>updaterules</code> feature easier, we provide a [[Template:Bulk Update|special user interface]].
Note: This template is deliberately not present, as it can apparently alter lots of wiki content. The line above is retained as a comment, since it was part of the original
''text'' is plain text; ''replacement'' is text which may contain references (like \1) to the matching ''pattern'' (provided that this pattern contains match groups).
Line 360 ⟶ 380:
{{DPL Parameter
|name = deleterules
|purpose=
}}
deleterules=
reason
exec ''true'';
This command is experimental at the moment.
This
[[Category:Primary Module|05]]
|