list filter in order of number of field items

74 views
Skip to first unread message

Dave

unread,
Mar 5, 2017, 7:18:23 PM3/5/17
to TiddlyWiki
Lets say you had three tiddlers

[[one]] [[two]] and [[three]], each with the  field "2017-03-05",
and in those fields were "one", "foo bar", and "this that [[the other]]"

how would you list these in order of the number of items in that field, weighting the more items to the top of the list (i.e. listing as "three two one")?



<<list-links "[has[2017-03-05]sort[index]]">>

...gives a list in the wrong order, so that doesn't work (I thought maybe index would count the number of items in the field.

I also tried playing around with "nsort" but couldn't find anything that worked.

Is this something that can be done natively?

Dave

unread,
Mar 7, 2017, 7:50:59 PM3/7/17
to TiddlyWiki
Okay, how about this (same idea but with tags)

<$list filter="[tags[]!is[system]sort[title]]">
<span class="cloud">
<$transclude tiddler="$:/core/ui/TagTemplate"/>
<$count filter="[all[current]tagging[]]"/>
</span>
</$list>


is there a way to sort by the "count" number given?

Mark S.

unread,
Mar 8, 2017, 12:29:20 AM3/8/17
to TiddlyWiki
I'm pretty sure it can't be done without an additional count filter and or macro -- AFAIK the results of the widget aren't available for use in the filter.

It looks like Tobias Beer may have what you're looking for, or at least a good start:

http://tobibeer.github.io/tw5-plugins/#count

I'm thinking that you might have to have an outer list that uses a filter of all known numerical counts values like "5 4 3 2 1" and then use and inner list with that matches those counts. This does mean that you will have to know your possible number ranges in advance.

As an example, I dropped this into a new tiddler at Tobias' site:

<$list filter="6 3 1" variable="cnt">

!!<
<cnt>>
<$list filter="[tags[]!is[system]]" >
<$set name="tagx" value=<
<currentTiddler>> >
<$list filter="[all[current]tagging[]] +[count
<cnt>]"><b><<tagx>></b><br/></$list>
<$list filter="[all[current]tagging[]] +[count:$
<cnt>]"><$view field="title"/><br/></$list>
</$set>
</$list>
</$list>


This shows the tags and the tiddlers they tag for where the number of tags is 6, 3, or 1.

Maybe this is a start?

Good luck,
Mark

Dave

unread,
Mar 8, 2017, 1:03:43 AM3/8/17
to TiddlyWiki
Thank you Mark,

I've come across the concept of inner and outer filters etc and was wondering if that was what I needed but didn't know where to start. This will be a good jumping off point :)

Reply all
Reply to author
Forward
0 new messages