Using a filter in a list field for sorting purposes

95 views
Skip to first unread message

Steven Schneider

unread,
Aug 8, 2017, 11:24:30 AM8/8/17
to TiddlyWiki
Hi, I am writing a syllabus for my course, and have a set of tiddlers tagged "Day" -- each has as a readable date as a title (i.e. Mon, Aug 28, 2017). I also want students to be able to navigate on a first-previous-next-last through the class meeting tiddlers, so I created a field called "sortable-date" which renders dates as 20170828, and thus can be sorted.

When I view <<tag Day>> the tiddlers are sorted by title, of course. How do I sort the tiddlers by sortable-date instead, when rendered in the <<tag Day>> macro?

I tried putting this in the list field of Day: <$list filter="[tag[Day]sort[sortable-date]]"/> but it didn't work. 

And, I tried creating a tiddler {{sortable-dates}} which is a space-separated ordered list of the tiddlers, and transcluding that tiddler into the list field of [[Day]] but that didn't work either.

Seems there should be an option the specifies the sort order of tiddlers matching a tag...so I must be missing something...

Thanks!

//steve.

Mark S.

unread,
Aug 8, 2017, 12:24:49 PM8/8/17
to TiddlyWiki
Well, the list mechanism specifies the ordering. So you could write a button that you fire off once a semester to specify the ordering. (Assuming the syllabus doesn't change during the semester, which would be evil)

Or you could hack your own tag button. If you make a  template $:/core/ui/TagTemplate2 like this:

\define list-tagged-draggable2(tag,itemTemplate,elementTag:"div")
<$set name="tag" value="""$tag$""">
<$list filter="[<tag>tagging[]sort[sortable-date]]">
<$elementTag$ class="tc-menu-list-item">
<$droppable actions=<<list-tagged-draggable-drop-actions>>>
<$elementTag$ class="tc-droppable-placeholder">
&nbsp;
</$elementTag$>
<$elementTag$>
<$transclude tiddler="""$itemTemplate$""">
<$link to={{!!title}}>
<$view field="title"/
>
</$link>
</
$transclude>
</$elementTag$>
</
$droppable>
</$elementTag$>
</
$list>
<$tiddler tiddler="">
<$droppable actions=<<list-tagged-draggable-drop-actions>>>
<$elementTag$ class="tc-droppable-placeholder">
&nbsp;
</$elementTag$>
<$elementTag$ style="height:0.5em;">
</
$elementTag$>
</$droppable>
</
$tiddler>
</$set>
\end
<span class="tc-tag-list-item">
<$set name="transclusion" value=<<currentTiddler>>>
<$macrocall $name="tag-pill-body" tag=<<currentTiddler>> icon={{!!icon}} colour={{!!color}} palette={{$:/
palette}} element-tag="""$button""" element-attributes="""popup=<<qualify "$:/state/popup/tag">> dragFilter='[all[current]tagging[]]' tag='span'"""/>
<$reveal state=<<qualify "$:/state/popup/tag">> type="popup" position="below" animate="yes" class="tc-drop-down">
<$transclude tiddler="$:/core/ui/ListItemTemplate"/>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TagDropdown]!has[draft.of]sort[sortable-date]]" variable="listItem">
<$transclude tiddler=<<listItem>>/>
</
$list>
<hr>
<$macrocall $name="list-tagged-draggable2" tag=<<currentTiddler>>/>
</
$reveal>
</$set>
</
span>
Enter code here...

and then create and invoke a new macro like:

\define tag2(tag)
{{$tag$||$:/core/ui/TagTemplate2}}
\end


<<tag2 mytag>>


Then the default ordering will be by sortable-date. Since the list is draggable , you can still rearrange the tiddlers as you want.

HTH
Mark 

stevesuny

unread,
Aug 10, 2017, 4:19:28 PM8/10/17
to TiddlyWiki
Thanks, Mark. I think the first mechanism is better for me :) but I appreciate the hack. It is pretty cool....i haven't used droppable yet, looks interesting....//steve.
Reply all
Reply to author
Forward
0 new messages