Hi,
I have some (video) tiddlers each of which has a “shared-with” field populated with the names of people I showed the video to. I would like to sort the tiddlers in a list by which has the most values entered in the “shared-with” field, i.e. which got shared with the most people (and therefore is most likely to be something I will want to share again in the future).
Would also like to append the count of the number of values in the shared-with field to the title in the list.
I searched the forum a long time. I tried to cobble something together with code I didn’t understand but it was so wrong I daren’t share it.
Thank you for any help.
Give this a try:
<$list filter="[has[shared-with]] :sort[enlist{!!shared-with}count[]] +[reverse[]]">
<$link/> (<$text text={{{ [enlist{!!shared-with}count[]] }}}/>)<br/>
</$list>
Notes:
-
[has[shared-with]] gives a list of tiddler titles that each have a non-blank shared-with field
-
:sort[enlist{!!shared-with}count[]] sorts the list of tiddler titles in ascending order by the number of items contained in each shared-with field
-
+[reverse[]] reverses the order of the titles so they will be output in descending order
- within the
$list widget, for each tiddler found:
-
<$link/> shows a link to the tiddler
-
(<$text text={{{ [enlist{!!shared-with}count[]] }}}/>) shows the number of items in the shared-with field for that tiddler
-
<br/> makes each tiddler appear on a separate line of output
enjoy,
-e
Yes! Thank you so much!
May I ask what code to add to not show those with a count under 2?
Change the filter like this:
<$list filter="[has[shared-with]] :filter[enlist{!!shared-with}count[]compare:integer:gteq[2]] :sort[enlist{!!shared-with}count[]] +[reverse[]]">
<$link/> (<$text text={{{ [enlist{!!shared-with}count[]] }}}/>)<br/>
</$list>
-
:filter[enlist{!!shared-with}count[]compare:integer:gteq[2]] retains only tiddler titles for which the shared-with count is “greater than or equal to” (gteq) 2.
enjoy,
-e