Issue:Dates in sortable tables
Description: | DPL does not allow sortable dates in tables |
Extension / Version: | DPL / |
Type / Status: | Bug / open |
Problem
The dpl output for a table in dates in it does not allow mediawiki data-sorting to work correctly.
- The mediawiki date sorting is very strict (wikibits.js) about what it recognises as a date. For example, for "01/02/2009" to be a date, it must have a length of exactly 10 characters and match a regular expression /^\d\d[\/.-]\d\d[\/.-]\d\d\d\d$/ (notice the start and end markers).
- The output from a DPL table contains extra characters (newline) that mean that an apparent date is not treated as so.
<tr> <td><a href="/mediawiki/index.php/Cust1" title="Cust1">Cust1</a> </td><td>01/02/2009 </td></tr>
Test case: Page Template:datetest contains
{{{date}}}
A page contains:
{{datetest|date=01/02/2009}} {{datetest|date=03/11/2009}} {{datetest|date=03/10/2009}} {{datetest|date=03/12/2009}} {{datetest|date=03/02/2010}}
Then the DPL script:
<dpl> uses=Template:Datetest include={Datetest}:date table=class="wikitable sortable",page,date </dpl>
Generates this output (after sorting)
C1 01/02/2009 C1 03/11/2009 C1 03/10/2009 C1 03/12/2009 C1 03/02/2010
Note that there is a line in wikibits.js that needs to be carefully adjusted...but in this case, it does not make a difference because the js is failing to recognise it as a date earlier than this.
var ts_europeandate = wgContentLanguage != "en"; //The non-American-inclined can change to "true"
I suggest that the solution is to modify DPL table generation to produce code like the following. Notice that the </td> is immediately after the content. There can be whitespce between </td> and the following <td>
<tr> <td><a href="/mediawiki/index.php/Cust1" title="Cust1">Cust1</a></td> <td>01/02/2009</td> </tr>
Reply
Thanks for the analysis and the suggestion. I will have a look at it. But it may take some weeks. Gero 08:50, 10 September 2008 (UTC)