Does anyone know how I can use the nsort operator to list all tiddler titles with the field release-date?
release-date will be using the YYYY-MM-DD format.
I have tried:
<$list filter="[all[]has[relese-date]]">
<$list filter="[all[current]nsort[release-date]before<currentTiddler>]"/>
<$list filter="[all[current]nsort[release-date]after<currentTiddler>]"/>
</$list>
If “SB” means “sortby”, then yes. That’s what I am trying to do.
Try something like this:
<$set name="tids" filter="[all[]has[release-date]sort[release-date]]">
<$list filter="[enlist<tids>allbefore<currentTiddler>]"><<currentTiddler>><br></$list>
<$list filter="[enlist<tids>allafter<currentTiddler>]"><<currentTiddler>><br></$list>
</$set>
Notes:
- The
$set gets and sorts all tiddlers that have release dates. Note that because your release-date field values use YYYY-MM-DD format, they aren’t actually numbers, so you should use sort[release-date] rather than nsort[release-date].
- The
release-date field values should use zero-padded date formatting (ie., YYYY-0MM-0DD). Otherwise some of the field values could contain single-digit numbers for the month or day and they won’t sort properly when compared with dates that have two-digit month or day numbers. I am assuming that you are already zero-padding the dates, but you didn’t specifically indicate that in your posted question.
- The inner
$list widgets enlist the already sorted list of tiddlers and then use allbefore<currentTiddler> or allafter<currentTiddler> to get the list of those tiddlers that occur before (or after) the current tiddler.
- You need to use the “long-form” of the
<$list><<currentTiddler>></$list> widget, otherwise the output will be a bunch of tiddler links without any spaces in-between.
enjoy,
-e
Thanks. I should have said I was using the YYYY-0MM-0DD format.
Just to add to the general knowledge here, given this is about sorting in release-date order you may wish to sort items with a version number 0.0.0
Then look at the sortsub Operator which includes;
- “version” - invalid versions are interpreted as “v0.0.0”