Difference between revisions of "Issue:Dates in sortable tables"

From FollowTheScore
Jump to: navigation, search
(New page: {{Issue |Type = Bug |Extension = DPL |Version = |Description = DPL does not allow sortable dates in tables |Status = open }} == Problem == The dpl output for a tab...)
 
Line 54: Line 54:
 
</pre>
 
</pre>
  
 +
I suggest that the solution is to modify DPL table generation to produce code like the following. Notice that the <nowiki></td></nowiki> is immediately after the content. There can be whitespce between <nowiki></td></nowiki> and the following <nowiki><td></nowiki>
 +
<pre>
 +
<tr>
 +
<td><a href="/mediawiki/index.php/Cust1" title="Cust1">Cust1</a></td>
 +
<td>01/02/2009</td>
 +
</tr>
 +
</pre>
  
  
 
== Reply ==
 
== Reply ==

Revision as of 09:47, 10 September 2008

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