Sort tiddlers tittles chronologically

236 views
Skip to first unread message

Eneko Gotzon

unread,
Jun 27, 2017, 8:28:19 PM6/27/17
to tiddl...@googlegroups.com
Hi Code Masters.

Well, I'm here once again asking another very basic question; please, excuse me about that.

I want the tiddlers (from a history book I'm writing) to be sorted chronologically by the date displayed inside their tittle, in order to show them as a list of tittles ordered from ancient times (using negative numbers?) to contemporary ones (using positive numbers?).

By default, TW5 can display the tiddlers as an alphabetic list. I don't know if it also can display them as a chronological one.

On the matter, I have not found information on the Internet. Maybe someone has enough knowledge, and time, to assist me.

​Thank you very much for all your wonderful work.​

​Take care.​

--
Eneko Gotzon Ares
eneko...@gmail.com

Mark S.

unread,
Jun 27, 2017, 10:32:56 PM6/27/17
to TiddlyWiki
You're overworking the title field. Ideally any data field in a database system should only contain one type of data. By embedding the date in the title, the field is actually doing 3 jobs (id, title, and date). Consider adding a date field. Then you can use the nsort filter operator to sort by that field.

Good luck,
Mark

PMario

unread,
Jun 28, 2017, 12:08:11 AM6/28/17
to TiddlyWiki
On Wednesday, June 28, 2017 at 4:32:56 AM UTC+2, Mark S. wrote:
You're overworking the title field. Ideally any data field in a database system should only contain one type of data. By embedding the date in the title, the field is actually doing 3 jobs (id, title, and date). Consider adding a date field. Then you can use the nsort filter operator to sort by that field.

+1 ... not much more to say. ...

You can play with this: <<list-links "[has[date]] +[nsort[date]]">>
and
create several tiddlers name: -300BC or whatever    date: -300
name -200  date: -200.02.28

have fun!
mario

Eneko Gotzon

unread,
Jun 28, 2017, 9:47:10 AM6/28/17
to tiddl...@googlegroups.com
Hi all.

On Wed, Jun 28, 2017 at 4:32 AM, 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:
You're overworking the title field

​Maybe it is an easiest approach to use an introductory tiddler as ​index, linking its references to the corresponding content tiddler. Do you agree?

Sorry about this kind of questions… :/

​Thank you.

Mark S.

unread,
Jun 28, 2017, 11:24:25 AM6/28/17
to TiddlyWiki
That's an easy way to start. But if you expect to have lots of tiddlers some day, it might be good to think about how to leverage TW5's various tools for listing and editing. When your list becomes large, maintaining all those links by hand will become harder.

If you apply a date field, then using PMario's suggested code your list might be generated in  a single lines, like:


<<list-links "[has[date]] +[nsort[date]]">>

One line of code, and you have all your dated tiddlers listed!

If you're worried about having to open and add those dates one by one, then a couple lines like this can make the job easier:

<table>
<tr><th>Tiddler</th><th>Date</th></tr>
<$list filter="[all[tiddlers]]" >
<tr><td><$view field="title"/></td><td><$edit-text field="date" tag="input" width="50"/></td></tr>
</$list>
</table>

You can just type in the date for each tiddler without having to open for editing. I used "all[tiddlers]" in the example, but that may be too many tiddlers at once. There are ways to manage that, but maybe this is good enough for now.

Be sure to test PMario's lister from time to time to make sure that things are sorting the way you expect. Generally, for computer sorting purposes, you want date fields to be designed to reflect increasing specificity. That is, you want your date to look like "yyyy-mm-dd" NOT "mm/dd/yyyy" because the latter will not sort meaningfully.

Good luck!
Mark

Eneko Gotzon

unread,
Jun 30, 2017, 12:49:26 AM6/30/17
to tiddl...@googlegroups.com
​Good morning.​

On Wed, Jun 28, 2017 at 5:24 PM, 'Mark S.' via TiddlyWiki <tiddl...@googlegroups.com> wrote:
if you expect to have lots of tiddlers some day…

​Mark & Mario: thank you ​very much for your teachings & code!

These days I'm caught up in court issues (as victim); as soon as I free up myself from, I'll test your suggestions.

Thank you!
Reply all
Reply to author
Forward
0 new messages