Sorting the timeline macro by created date

Hi,

In the timeline macro e.g. at Kookma’s site the results can be sorted using an additional date field e.g.

<<timeline-vertical filter:"[tag[quote]!sort[date]]" class:warning>>

How can I sort by the created date? ([tag[quote]!sort[created]] doesn’t work).

Thanks
Jon.

It works fine as far as I can tell. :thinking: The syntax requires separating out the date element, like this:

<<timeline-vertical filter:"[tag[quote]]" date:"created" class:"primary">>

But perhaps I’m not understanding your question, since you refer to “another” date field… are you talking about a complex sort, where a second field controls the sort order for tiddlers that share the main/primary date for the timeline?

1 Like

It looks like your filter with reverse sort is getting overridden by the macros internal sort on date field which defaults to Modified date…?

Can you show how you sorted it?

In the first example, the sort[date]] refers to an additional field in each tiddler named “date” and sorting by that works.

However, I don’t want to add an additional date field to the tiddlers I want to put in a timeline, but would rather sort them by their created date.

Hope that makes sense
Jon

Yeah, I think it’s being over ridden.
No doubt there’s a way round it somehow

Another approach is not to me using a third party macro but the core timeline macro see “timeline Macro”.

  • It has provision for

dateField
The name of the date field to use, defaulting to modified

  • So open the tiddler that that shows the recent tab $:/core/ui/SideBar/Recent
  • Clone it eg $:/my/SideBar/Recent-created
  • add dateField=created as a parameter in the macro call
  • Add created at the end of the caption field.
<$macrocall $name="timeline" dateField=created format={{$:/language/RecentChanges/DateFormat}}/>

Thanks Tones, I’ll play around with that later.

Nope, I don’t know where to insert the dateField into @Mohammad’s timeline format so that the timeline can be sorted on the created date. Has anyone else done this?

@Jon try my suggested approach, it will get what you need and may help you modify mohamads solution as a result.

The first line of the macro definition tiddlers sets the default to “modified”, you can changes these two tiddlers or clone and generate your own unique macro name:

$:/plugins/kookma/timelines/macros/timeline-horizontal
$:/plugins/kookma/timelines/macros/timeline-vertical

First line just requires date:"modified" to be replaced with date:"created".

\define timeline-vertical(filter, limit:10, template:"", footer:"footer", class:"light", date:"modified", dateformat:"mmm 0DDth YYYY")

The attached contains cloned versions for timeline-horizontal-created macro and a timeline-vertical-created macro with examples in use.

ModifiedTimeLinesMacro_tiddlers.json (5.3 KB)

Thanks for looking into this.

Full disclosure - I’m a complete noob in terms of understanding this stuff but I don’t think that works as far as I can see. However, fully prepared to be corrected! :upside_down_face:

Using the demo/timeline-vertical/primary tiddler at Kookma’s site, changing the “modified” date to “created” in the macro, alters the date displayed vertically on the left as can be seen in the screenshots.

In the second screenshot, I’ve added the date sort and this works because each tiddler has a field called “date” - but what I want to do is sort the tiddlers on their created date.

What puzzles me is that sorting by the created date would seem to be a default choice (why would each tiddler have a manually added date field?) so I feel like I must be missing something glaringly obvious.

Yeah, as mentioned, I don’t know where that would go - but wouldn’t it just change the vertical date displayed as shown in the 2 screenshots?

If no date is supplied in the macro, it defaults to “modified”. you can override that behavior by providing date input. Here are three examples: default, created and userdate. It doesn’t appear to support reverse sort.

2 Likes

Got it thanks!

What threw me is that when changing from modified to created, I was expecting the order of the quotes in the example to change - they don’t because the created dates for each are identical!

However, I need the most recent entries on my timeline first (by created date rather than user date) so it is the reverse sort order I want.

The macro has a sort built in which is why your reverse sort filter wasn’t working. You could tweak the macro to always reverse sort. I see that handling reverse sort is on the (Timelines 1.3.0 — a graphical representation of a period of time) for timelines…

2 Likes

Ah yes - that worked:

Changed <$list filter="[subfilter<__filter__>] :sort:date[get<__date__>] section in the macro to <$list filter="[subfilter<__filter__>] :sort:date:reverse[get<__date__>]

Thanks
Jon

2 Likes