Last modified: 2012-02-12 14:20:10 UTC
I've got pages that each have multiple SIO records, and each record includes a date (Status Report Date of type Date). I was able to create a 2 column summary table that lists each page along with the date of the newest record with this query: <pre> {{#ask:[[Category:Status Report]] [[Has Contributor::{{PAGENAME}}]] |?Has Effort=Effort |link=none |sort=Has Effort |format=template |template=display2ColTableViewStatusReportEntry |intro={{display2ColSortTableHeader |col1=Effort |col2=Last Update}} |outro={{displayTableFooter}} }} </pre> where Template:display2ColTableViewStatusReportEntry holds <pre> | [[{{{1}}}#{{#ask: [[Status Report Record::{{{1}}}]] |?Has Status Report Date= |sort=Has Status Report Date |format=list |limit=1 |order=descending |mainlabel=- |link=none |headers=hide |searchlabel= }}|{{{2}}} - View]] | {{#ask: [[Status Report Record::{{{1}}}]] |?Has Status Report Date= |sort=Has Status Report Date |format=list |limit=1 |order=descending |mainlabel=- |link=none |headers=hide |searchlabel= }} |- </pre> This results in a column sort table like <pre> Effort v Last Update Soda Project - View 4 November 2010 Burger Project - View 25 October 2010 Hot Dog Project - View 20 May 2010 Sandwich Project - View 19 October 2010 </pre> The table shown above replicates one sorted by Last Update in descending order. It sorts alphanumerically rather than by date.
*** This bug has been marked as a duplicate of bug 25807 ***
*** Bug 25807 has been marked as a duplicate of this bug. ***
First, this bug is not "critical". Mainly, the issue is a basic limitation of the "recipe" at [1] and this recipe should warn about this. SMW takes special precautions to avoid this problem in its own tables. By using a manually created table, this special handling is eliminated. The sortable table code of MediaWiki cannot handle dates. To make them sort properly, one needs to provide numeric sortkeys using the "data-sort-value" attribute in td elements (look at the HTML of any real SMW table for examples). When manually creating tables, one is in charge of providing this information, or one needs to use JavaScript that can handle dates natively (which is difficult due to the complex format). To allow this to be done manually, I have now (in r111269) added a new output format "sortkey" to Type:Date by which one can obtain a numeric sortkey as needed for "data-sort-value". For example, the following query displays dates and their sortkeys: {{#ask: [[Modification date::+]] | ?Modification date | ?Modification date#sortkey }} For properties that can have many values, only one sortkey must be used (since the whole table row is sorted as one, even if many dates are in one cell). This can be achieved by using +limit like so: {{#ask: [[testdate::+]] | ?testdate | ?testdate#sortkey |+limit=1 }} It would be nice if the recipe could be extended by all this information, and ideally with a recipe for building the correct HTML code. This goes as far as SMW can assist the manual creation of sortable tables, so I am closing this bug. [1] http://smw.referata.com/wiki/Use_the_ask_template_format_to_create_tabular_output
The best would be to make the recipe obsolete by implementing some better 'format results' syntax, but I see that this is not easy. In the meantime, I'll just put a pointer there to here. Cheers,