Controlling output order: Difference between revisions
Content added Content deleted
imported>FrozenPlum mNo edit summary |
imported>FrozenPlum m (Add a category sortkey, so these can be displayed in the correct order on the parameter quick reference page. I still need to go through this page (when I'm finished the others that are more complex) and do all the examples, plus more content fixes.) |
||
Line 8: | Line 8: | ||
But there is another way: Create a ''sortable wiki table'' (using the {{DPL|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 {{DPL|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 |
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 19: | Line 19: | ||
ts_resortTable(lnk); |
ts_resortTable(lnk); |
||
Before version 1.16 of MediaWiki, ''wikibits.js'' was typically 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. |
|||
Line 81: | Line 81: | ||
'''Syntax:'''< |
'''Syntax:''' <code>order=<i>orderdirection</i></code> |
||
<code>order=<i>orderdirection</i></code> |
|||
''orderdirection'' can be one of: |
''orderdirection'' can be one of: |
||
Line 91: | Line 89: | ||
If combined with <code>{{DPL|ordermethod}}</code>, the <code>''ascending''</code> and <code>''descending''</code> values can control the sort direction of some ordermethod values, such as <code>ordermethod=''title''</code>. |
If combined with <code>{{DPL|ordermethod}}</code>, the <code>''ascending''</code> and <code>''descending''</code> values can control the sort direction of some ordermethod values, such as <code>ordermethod=''title''</code>. |
||
⚫ | |||
* ''descending'' — outputs list from most recent to least recent |
* ''descending'' — outputs list from most recent to least recent |
||
* ''ascending'' — outputs list from least recent to most recent — '''(default)''' |
* ''ascending'' — outputs list from least recent to most recent — '''(default)''' |
||
<pre><nowiki> |
|||
⚫ | |||
<pre> |
|||
{{#dpl: |
{{#dpl: |
||
|category = Africa |
|category = Africa |
||
Line 105: | Line 102: | ||
|addeditdate = true |
|addeditdate = true |
||
}} |
}} |
||
</pre> |
|||
This |
This will list pages that have <nowiki>[[Category:Africa]]</nowiki> shown, ordered from oldest to newest. |
||
In addition, the edit date will be presented with each article. |
In addition, the edit date will be presented with each article. |
||
Line 115: | Line 112: | ||
{{DPL Parameter |
{{DPL Parameter |
||
|name = ordercollation |
|name = ordercollation |
||
|purpose= |
|purpose= Defines the collating sequence for ordering. Allows individual collations, makes case-insensitive sorting possible. |
||
}} |
}} |
||
defines the collating sequence for ordering. |
|||
⚫ | |||
'''Example:'''<br> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
If you use a name for the first time, you should make sure that it is spelled correctly. Otherwise, you will see a SQL error message. |
|||
'''Notes:''' |
|||
For case insensitivity during the ''selection'' of articles, see {{DPL|ignorecase}}. |
* For case insensitivity during the ''selection'' of articles, see {{DPL|ignorecase}}. |
||
⚫ | |||
⚫ | |||
==References== |
==References== |
||
<references /> |
<references /> |
||
[[Category:Primary Module]] |
[[Category:Primary Module|03]] |