[pmwiki-users] Sort a table when opening a page

Petko Yotov 5ko at 5ko.fr
Fri Jan 5 09:56:50 PST 2024


The "sortable" tables are only ordered when the user clicks on a column 
header, and only on the content in every cell, either numerical, or 
alphabetical, so Lundi (Monday) would be sorted after Dimanche (Sunday).

It should be possible to order a pagelist by date or by day of week, if 
some property or variable for every page is a date.

Say you have this date as a page text variable in every page:

    Date: 2024-01-05
or

   (:Date:2024-01-05:)

Then you can order your pagelist by the $:Date variable:

   (:pagelist [other options] order=$:Date:)

In a pagelist template, knowing the date, you can print the day of week 
in French with this markup expression:

   {(ftime fmt=%A when={=$:Date} locale=fr_FR.utf8 tz=Europe/Paris)}

The "locale" and "tz" arguments may not be needed if your wiki is 
correctly configured.

BTW you can show this international date 2024-01-05 in the European 
format like this:

   {(ftime fmt=%d/%m/%Y when={=$:Date} )} (shows 05/01/2024)

See the documentation on these pages:

   https://www.pmwiki.org/wiki/PmWiki/PageLists#pagelistorder
   https://www.pmwiki.org/wiki/PmWiki/PageListTemplates
   https://www.pmwiki.org/wiki/PmWiki/PageTextVariables
   https://www.pmwiki.org/wiki/PmWiki/MarkupExpressions#ftime
   https://www.php.net/manual/en/function.strftime.php

Petko

-- 
If you upgrade :  https://www.pmwiki.org/Upgrades

On 05/01/2024 11:05, Benjamin Grassineau wrote:
> Hello list ! Happy new year !
> 
> Here's my problem. First, I create a table with pagelist. Then, I
> would like it to be sorted by the time it appears to the reader of the
> page (ordered by days of week (fr)). Unfortunately the function
> 'order' of pagelist is not enough for this (because of multiple lines
> per each result).
> 
> for example :
> 
>  		EVENT
>  		JOURS
> 
>  festival
>  		Lundi
> 
>  noel
>  		Dimanche
> 
>  good day
>  Samedi
> 
>  arrivée
>  Vendredi
> 
> should be :
> 
>  		EVENT
>  		JOURS
> 
>  festival
>  		Lundi
> 
>  arrivée
>  Vendredi
> 
>  good day
>  Samedi
> 
>  noël
>  Dimanche
> 
> Is it possible to use the sortable directive for this ? ex :
> class=sortable
> 
> I did not find if the function exists.
> 
> Thanks a lot for your help !
> 
> --
>  Benjamin Grassineau
> 
>  Sociologue [1]



More information about the pmwiki-users mailing list