Query: Add Modified Date To Tag Pill Sorter. How?

38 views
Skip to first unread message

TiddlyTweeter

unread,
Jun 6, 2020, 5:38:42 AM6/6/20
to TiddlyWiki
Over on TW-Scripts there is a very neat sorter that integrates into tag pills.

I'm crap at coding. Could someone show me how to ADD a button to sort on Modified Date?

Here is the code as is ...

\define tagSortFunc(mainTag, order:"ascend")

<$reveal type="match" default="ascend" text=<<__order__>> >
<$action-listops  $tiddler=<<__mainTag__>>  $filter="[tag<__mainTag__>sortan[]]"/>
</$reveal>

<$reveal type="nomatch" default="ascend" text=<<__order__>> >
<$action-listops  $tiddler=<<__mainTag__>>  $filter="[tag<__mainTag__>!sortan[]]"/
>
</$reveal>


\end

\define sortInTagDropdown()

<$button tooltip="Sort tiddlers A → Z" aria-label="Sort tiddlers A → Z" class='tc-btn-invisible'>Sort {{!!title}} tiddlers A → Z
<$macrocall $name="tagSortFunc" mainTag={{!!title}}/
>
</$button>

<$button tooltip="Sort tiddlers Z → A" aria-label="Sort tiddlers Z → A" class='tc-btn-invisible'>Sort {{!!title}} tiddlers Z → A
<$macrocall $name="tagSortFunc" mainTag={{!!title}} order="no-ascend"/
>
</$button>

\end

<<sortInTagDropdown>>

Best wishes
TT

Eric Shulman

unread,
Jun 6, 2020, 6:05:26 AM6/6/20
to TiddlyWiki
On Saturday, June 6, 2020 at 2:38:42 AM UTC-7, TiddlyTweeter wrote:
Over on TW-Scripts there is a very neat sorter that integrates into tag pills.
I'm crap at coding. Could someone show me how to ADD a button to sort on Modified Date?

Here's new code that includes sorting by modified date, ascending (oldest first) or descending (newest first)

\define tagSortFunc(mainTag, order:"ascend")

<$reveal type="match" default="ascend" text=<<__order__>> >
<$action-listops  $tiddler=<<__mainTag__>>  $filter="[tag<__mainTag__>sortan[]]"/>
<
/$reveal>

<$reveal type="match" default="oldest" text=<<__order__>> >
<$action-listops  $tiddler=<<__mainTag__>>  $filter="[tag<__mainTag__>sort[modified]]"/
>
</$reveal>

<$reveal type="match" default="newest" text=<<__order__>> >
<$action-listops  $tiddler=<<__mainTag__>>  $filter="[tag<__mainTag__>!sort[modified]]"/
>
</$reveal>

<$reveal type="match" default="no-ascend" text=<<__order__>> >

<$action-listops  $tiddler=<<__mainTag__>>  $filter="[tag<__mainTag__>!sortan[]]"/
>

</$reveal>

\end


\define sortInTagDropdown()

<$button tooltip="Sort tiddlers A → Z" aria-label="Sort tiddlers A → Z" class='tc-btn-invisible'>Sort {{!!title}} tiddlers A → Z
<$macrocall $name="tagSortFunc" mainTag={{!!title}}/
>
</$button>

<$button tooltip="Sort tiddlers Z → A" aria-label="Sort tiddlers Z → A" class='tc-btn-invisible'>Sort {{!!title}} tiddlers Z → A
<$macrocall $name="tagSortFunc" mainTag={{!!title}} order="no-ascend"/
>
<
/$button>

<$button tooltip="Sort tiddlers modified (oldest first)" aria-label="Sort tiddlers  modified (oldest first)" class='tc-btn-invisible'>Sort {{!!title}} tiddlers modified (oldest first)
<$macrocall $name="tagSortFunc" mainTag={{!!title}} order="oldest"/
>
</$button>

<$button tooltip="Sort tiddlers modified (newest first)" aria-label="Sort tiddlers  modified (newest first)" class='tc-btn-invisible'>Sort {{!!title}} tiddlers modified (newest first)
<$macrocall $name="tagSortFunc" mainTag={{!!title}} order="newest"/
>
</$button>

\end

<<sortInTagDropdown>>

notes:
* in sortInTagDropdown(), I added two new buttons that invoke tagSortFunc() with order="oldest" and order="newest"
* in tagSortFunc(), I added new handling for "oldest" and "newest".
* I also changed the $reveal for "nomatch","ascend"  to use "match","no-ascend"

enjoy,
-e

TiddlyTweeter

unread,
Jun 6, 2020, 6:47:32 AM6/6/20
to TiddlyWiki
Eric

Thank you! Superb. And with the added code its much clearer to me how I could modify it myself if I needed to in the future.

Regards, TT
Reply all
Reply to author
Forward
0 new messages