Gamepedia Help Wiki
Azxiana (talk | contribs)
No edit summary
No edit summary
 
(21 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{DPL Manual|section=Controlling output order}}
+
{{DPL manual|section=Parameters|subsection=Controlling output order}}
   
DPL allows you to define the sort order of its output as is explained below.
+
DPL3 allows you to define the sort order of its output as is explained below.
   
In some cases this is not sufficient, however. Think of the following example: You create a list of pages which use a certain template. You want to show the value of the first parameter each page uses when calling that template. This can easily be done with the [[include]] feature of DPL. If you now wanted the output to be sorted by the value of that parameter DPL could not help because it had to analyse all articles before finding those parameter values.
+
In some cases this is not sufficient, however. Think of the following example: You create a list of pages which use a certain template. You want to show the value of the first parameter each page uses when calling that template. This can easily be done with the {{dpl3|include}} feature of DPL. If you now wanted the output to be sorted by the value of that parameter DPL could not help because it had to analyze all articles before finding those parameter values.
   
But there is another way: Create a ''sortable wiki table'' (using the [[table]] option of DPL with 'class=sortable') and you can click on the column headings to sort your output accordingly. However, the initial order shown in that table will still be the order in which DPL parsed the wiki pages (usually an alphabetic order of the page names).
+
But there is another way: Create a ''sortable wiki table'' (using the {{dpl3|table}} option of DPL with 'class=sortable') and you can click on the column headings to sort your output accordingly. However, the initial order shown in that table will still be the order in which DPL parsed the wiki pages (usually an alphabetic order of the page names).
   
Using a handful of javascript lines you can sort a wikitable ''on pageLoad'' by any column. You must use an extension like [[Javascript extension]] or find some other way to insert that javascript code AT THE END of your page :
+
Using a handful of javascript lines you can sort a wikitable ''on pageLoad'' by any column. You must insert that javascript code AT THE END of your page :
   
 
sortables_init();
 
sortables_init();
Line 18: Line 18:
 
ts_resortTable(lnk);
 
ts_resortTable(lnk);
   
The ''wikibits.js'' usually is called at the end of a page and performs ''sortables_init()''. If we call it ourselves it will not recognize this and therefore it will add its sort link buttons a second time (which looks quite funny...). You can teach wikibits.js to be aware of initialized sortable tables by adding the following if-statement around the line where it inserts the href for the sort button (near line 550 in MW 1.13):
+
Prior to version 1.16 of MediaWiki, ''wikibits.js'' was usually called at the end of a page and performed ''sortables_init()''. Calling it explicitly did not result in it being recognized, but rather resulted in adding a second set of sort link buttons.
if (cell.innerHTML.indexOf("sortheader") < 0) { ... place the original code line here ... }
 
   
 
==ordermethod==
   
  +
{{DPL Parameter
__TOC__
 
 
 
===ordermethod===
 
 
{{DPL parameter
 
 
|name = ordermethod
 
|name = ordermethod
|purpose= Determines what criterium (resp. criteria) is (resp. are) used to order the list.
+
|purpose= Determines what criterion (resp. criteria) is (resp. are) used to order the list.
 
}}
 
}}
   
Line 39: Line 34:
   
 
;''categoryadd'': outputs list based on most recent addition to the first category (requires to include one category and one only using 'category' parameter)
 
;''categoryadd'': outputs list based on most recent addition to the first category (requires to include one category and one only using 'category' parameter)
;''counter'': outputs list based on the number of times the page has been viewed (by ~popularity)
+
;''counter'': outputs list based on the number of times the page has been viewed (by ~popularity) : '''Attention:''' Requires the [https://www.mediawiki.org/wiki/Extension:HitCounters HitCounter Extension] for wikis on MediaWiki 1.25.0 or higher since the counter feature was removed<ref>[https://www.mediawiki.org/wiki/Manual:$wgDisableCounters Manual:$wgDisableCounters]</ref>.
 
;''size'': outputs list based on the size of the article (bytes of wiki text)
 
;''size'': outputs list based on the size of the article (bytes of wiki text)
 
;''firstedit'': outputs list based on first edit to the pages (creation)
 
;''firstedit'': outputs list based on first edit to the pages (creation)
 
;''lastedit'': outputs list based on most recent edit to the pages
 
;''lastedit'': outputs list based on most recent edit to the pages
 
;''pagetouched'': outputs list based on 'page_touched' timestamp. Read comment on <code>page_touched</code> field in [[mw:Page_table|Page_table]] to see the difference from most recent edit by an author.
 
;''pagetouched'': outputs list based on 'page_touched' timestamp. Read comment on <code>page_touched</code> field in [[mw:Page_table|Page_table]] to see the difference from most recent edit by an author.
;''pagesel'': outputs list based on the names of the reference pages which are used in the selection of a <tt>linksfrom</tt> or <tt>linksto</tt> statement. ''pagesel'' only makes sense if there is more than one page mentioned in the <tt>linksfrom</tt> or <tt>linksto</tt> condition.
+
;''pagesel'': outputs list based on the names of the reference pages which are used in the selection of a <code>linksfrom</code> or <code>linksto</code> statement. ''pagesel'' only makes sense if there is more than one page mentioned in the <code>linksfrom</code> or <code>linksto</code> condition.
 
;''title'': outputs list sorted by article (prefix +) title
 
;''title'': outputs list sorted by article (prefix +) title
;''titlewithoutnamespace'': outputs list sorted by the article name regardless of namespace &mdash; '''(default)'''
+
;''titlewithoutnamespace'': outputs list sorted by the article name regardless of namespace
   
''methodN'' can also be one of the following token combinations (see also [[DPL parameters: Controlling output format#headingmode|''headingmode'']] option):
+
''methodN'' can also be one of the following token combinations (see also [[Extension:DPL3/Parameters: Controlling output format#headingmode|''headingmode'']] option):
   
 
;''category,firstedit'': outputs list sorted by category, then by first edit
 
;''category,firstedit'': outputs list sorted by category, then by first edit
Line 58: Line 53:
 
;''user,lastedit'': outputs list sorted by user, then by lastedit by the user
 
;''user,lastedit'': outputs list sorted by user, then by lastedit by the user
   
;''none'': do not apply any ordering (except ordering by timestamp if you requested a list of revisions); this method '''must be used when you specify '''openreferences=yes'''.
+
;''none'': do not apply any ordering (except ordering by timestamp if you requested a list of revisions); this method '''must be used when you specify '''openreferences=yes'''. &mdash; '''(default)'''
 
Note:
 
For downward compatibility reasons DPL will use 'addfirstcategory' as its default order method if called via the &lt;dynamicPageList&gt;
 
   
 
Example:
 
Example:
   
 
<pre><nowiki>
 
<pre><nowiki>
  +
{{#dpl:
<DPL>
 
category=Africa
+
|category=Africa
ordermethod=lastedit
+
|ordermethod=lastedit
  +
}}
</DPL>
 
 
</nowiki></pre>
 
</nowiki></pre>
   
 
This list will output pages that have <nowiki>[[Category:Africa]]</nowiki> showing most recently edited articles at the top.
 
This list will output pages that have <nowiki>[[Category:Africa]]</nowiki> showing most recently edited articles at the top.
   
===order===
+
==order==
   
{{DPL parameter
+
{{DPL Parameter
 
|name = order
 
|name = order
 
|purpose= Controls the sort direction of the list.
 
|purpose= Controls the sort direction of the list.
Line 92: Line 84:
   
 
<pre><nowiki>
 
<pre><nowiki>
  +
{{#dpl:
<DPL>
 
category = Africa
+
|category = Africa
ordermethod = lastedit
+
|ordermethod = lastedit
order = ascending
+
|order = ascending
addeditdate = true
+
|addeditdate = true
  +
}}
</DPL>
 
 
</nowiki></pre>
 
</nowiki></pre>
   
Line 103: Line 95:
 
In addition the edit date will be presented with each article.
 
In addition the edit date will be presented with each article.
   
 
==ordercollation==
   
  +
{{DPL Parameter
===ordercollation===
 
 
{{DPL parameter
 
 
|name = ordercollation
 
|name = ordercollation
 
|purpose= Allow individual collations, make case insensitive sorting possible
 
|purpose= Allow individual collations, make case insensitive sorting possible
Line 113: Line 104:
 
defines the collating sequence for ordering.
 
defines the collating sequence for ordering.
   
Note: A very special (proprietory) function can be used to sort card suit symbols according to the rank of suits that is used in the card game of bridge (this cannot be done by standard collating sequences). To trigger this function set <tt>ordercollation=bridge</tt>.
+
Note: A very special (proprietory) function can be used to sort card suit symbols according to the rank of suits that is used in the card game of bridge (this cannot be done by standard collating sequences). To trigger this function set <code>ordercollation=bridge</code>.
   
 
Example:
 
Example:
Line 119: Line 110:
 
<code>ordercollation=<i>latin1_german_ci</i></code>
 
<code>ordercollation=<i>latin1_german_ci</i></code>
   
You may want to try <tt>latin1_swedish_ci</tt> or other collation mapping table names as well.
+
You may want to try <code>latin1_swedish_ci</code> or other collation mapping table names as well.
   
 
If you use a name for the first time you should make sure that it is correctly spelt. Otherwise you will see a SQL error message.
 
If you use a name for the first time you should make sure that it is correctly spelt. Otherwise you will see a SQL error message.
   
For case insensitivity during the ''selection'' of articles, see [[ignorecase]].
+
For case insensitivity during the ''selection'' of articles, see {{dpl3|ignorecase}}.
  +
  +
==References==
  +
<references />
  +
  +
<!-- Extension prefix in other languages:
  +
  +
[[de:Erweiterung:{{subst:BASEPAGENAME}}]]
  +
[[es:Extensión:{{subst:BASEPAGENAME}}]]
  +
[[fr:Extension:{{subst:BASEPAGENAME}}]]
  +
[[it:Estensione:{{subst:BASEPAGENAME}}]]
  +
[[nl:Uitbreiding:{{subst:BASEPAGENAME}}]]
  +
[[pl:Rozszerzenie:{{subst:BASEPAGENAME}}]]
  +
[[pt:Extensão:{{subst:BASEPAGENAME}}]]
  +
[[ru:Расширение:{{subst:BASEPAGENAME}}]]
  +
[[zh:扩展:{{subst:BASEPAGENAME}}]]
  +
-->

Latest revision as of 16:42, 13 November 2020

Manual Parameters Controlling output order

DPL3 allows you to define the sort order of its output as is explained below.

In some cases this is not sufficient, however. Think of the following example: You create a list of pages which use a certain template. You want to show the value of the first parameter each page uses when calling that template. This can easily be done with the include feature of DPL. If you now wanted the output to be sorted by the value of that parameter DPL could not help because it had to analyze all articles before finding those parameter values.

But there is another way: Create a sortable wiki table (using the table option of DPL with 'class=sortable') and you can click on the column headings to sort your output accordingly. However, the initial order shown in that table will still be the order in which DPL parsed the wiki pages (usually an alphabetic order of the page names).

Using a handful of javascript lines you can sort a wikitable on pageLoad by any column. You must insert that javascript code AT THE END of your page :

 sortables_init();
 // sort the first sortable table; change [0] to sort other tables.
 tab = document.getElementsByTagName("table")[0];
 // sort by the first column; change [0] to sort by other columns.
 hdr = tab.getElementsByTagName("th")[0];
 // get the sort button link
 lnk = hdr.getElementsByTagName("a")[0];
 ts_resortTable(lnk);

Prior to version 1.16 of MediaWiki, wikibits.js was usually called at the end of a page and performed sortables_init(). Calling it explicitly did not result in it being recognized, but rather resulted in adding a second set of sort link buttons.

ordermethod

ordermethod Determines what criterion (resp. criteria) is (resp. are) used to order the list.

Syntax:

ordermethod=method1,method2,... means ordered by method1 first, then by method2, etc. (like the ORDER BY clause in SQL)

methodN can be one of the following single tokens:

categoryadd
outputs list based on most recent addition to the first category (requires to include one category and one only using 'category' parameter)
counter
outputs list based on the number of times the page has been viewed (by ~popularity) : Attention: Requires the HitCounter Extension for wikis on MediaWiki 1.25.0 or higher since the counter feature was removed[1].
size
outputs list based on the size of the article (bytes of wiki text)
firstedit
outputs list based on first edit to the pages (creation)
lastedit
outputs list based on most recent edit to the pages
pagetouched
outputs list based on 'page_touched' timestamp. Read comment on page_touched field in Page_table to see the difference from most recent edit by an author.
pagesel
outputs list based on the names of the reference pages which are used in the selection of a linksfrom or linksto statement. pagesel only makes sense if there is more than one page mentioned in the linksfrom or linksto condition.
title
outputs list sorted by article (prefix +) title
titlewithoutnamespace
outputs list sorted by the article name regardless of namespace

methodN can also be one of the following token combinations (see also headingmode option):

category,firstedit
outputs list sorted by category, then by first edit
category,lastedit
outputs list sorted by category, then by last edit within a category
category,pagetouched
outputs list sorted by category, then by pagetouched
category,sortkey
sortkey
outputs list sorted by title and sortkey, requires at least one category statement
user,firstedit
outputs list sorted by user, then by firstedit by the user
user,lastedit
outputs list sorted by user, then by lastedit by the user
none
do not apply any ordering (except ordering by timestamp if you requested a list of revisions); this method must be used when you specify openreferences=yes. — (default)

Example:

{{#dpl:
|category=Africa
|ordermethod=lastedit
}}

This list will output pages that have [[Category:Africa]] showing most recently edited articles at the top.

order

order Controls the sort direction of the list.

Example:

order=orderdirection

orderdirection can be one of:

  • descending — outputs list from most recent to least recent
  • ascending — outputs list from least recent to most recent — (default)

Example:

{{#dpl:
|category    = Africa
|ordermethod = lastedit
|order       = ascending
|addeditdate = true
}}

This list will output pages that have [[Category:Africa]] shown ordered from oldest to newest. In addition the edit date will be presented with each article.

ordercollation

ordercollation Allow individual collations, make case insensitive sorting possible

defines the collating sequence for ordering.

Note: A very special (proprietory) function can be used to sort card suit symbols according to the rank of suits that is used in the card game of bridge (this cannot be done by standard collating sequences). To trigger this function set ordercollation=bridge.

Example:

ordercollation=latin1_german_ci

You may want to try latin1_swedish_ci or other collation mapping table names as well.

If you use a name for the first time you should make sure that it is correctly spelt. Otherwise you will see a SQL error message.

For case insensitivity during the selection of articles, see ignorecase.

References