listing related tags (not children or parents)

70 views
Skip to first unread message

haroulito

unread,
Nov 3, 2018, 5:17:52 PM11/3/18
to TiddlyWiki
Dear TW community,
I am using TiddlyWiki a lot lately but I am a novice in terms of fiddling with it. I am looking for a way to list related tags to a list of tiddlers (returned by list filter, for instance). I've searched a few times but can't find something and I'm wondering whether there is an easy way to implement it.

A simple scenario is given below:
Let's say tiddler1 tags two other tiddlers (tiddler2 & tiddler3) and when we run list filter it returns:
  • tiddler2
  • tiddler3
I then need to get the parent tiddlers of tiddler2 (i.e those tagging tiddler2, as opposed to those tagged by tiddler2 which we can get with list filter or toc-selective-expandable).

I need to do the same for tiddler3, aggregate and list the results (ideally with a count of the number of tiddlers tagged by each "related" tag). This way I can see that tiddler2 which is tagged by tiddler1 is also tagged by e.g. tiddler4. This helps to view how I can narrow down long lists of results through the use of "related" tags.

Another way to view this might be: for a given tiddler go one level down in the toc tree, see if any of the branches intersect with other toc trees and get all parents of the intersections.

Any hints as to how to implement this? Apologies if a solution exists and I haven't come across it. I just came across the filter/plugin by bimlas but didn't have a chance to test it yet so not sure if it will tackle the problem.

Many thanks
haroulito

p.s.1.
I found the following code in http://tobibeer.github.io/tb5/#Conditional%20ViewTemplate%20Section which might do part of the job but I cannot get it to work:

<$list filter="[all[current]tag[Project]]">

<$list filter="[all[current]tagging[]]"/>

</$list>

p.s. 2
This is my first post here and I have to say that Tiddlywiki is simply amazing and the community is very helpful.

bimlas

unread,
Nov 3, 2018, 6:13:24 PM11/3/18
to TiddlyWiki
Welcome to the community!

I tried the code you wrote, but it did not work nor for me, so I modified it:

<$list filter="[tag[Project]tags[]]"/>

It collects all the tiddlers that have the "Project" tag and then collects their other tags.

If I understand you, you are actually interested in the tag intersections, thus you might find it useful:

Mark S.

unread,
Nov 3, 2018, 6:18:15 PM11/3/18
to TiddlyWiki
It's a little hard to understand your use-case, but if I understand right, then this might do what you want:

<$set name="tag" value="tiddler1">
<$list filter="[tag
<tag>tags[]] -[tag<tag>] -[<tag>]">

</$list>
</$set>

(that blank space in the middle is important, BTW).

The tag value gets set as a variable and then used in the filter. First it finds all the items tagged by "tiddler1", then all the tags of those items. Then it subtracts all the items tagged by "tiddler1" and the value of "tiddler1" itself.

HTH
-- Mark

TonyM

unread,
Nov 3, 2018, 7:52:53 PM11/3/18
to TiddlyWiki
The first thing that comes to mind with your request is two nested lists, one to list the tiddlers, the inner to list tiddlers tags and do what you want for each of the listed tiddlers.

You need to close every list widget with </$list> unlike the example at the end of your post.

What you ask can be done easily, it just takes adding the pieces together.

Regards
Tony

haroulito

unread,
Nov 4, 2018, 5:41:22 AM11/4/18
to TiddlyWiki
Dear bimlas, Mark and Tony,
Many thanks for your replies.

@bimlas: Your code did the trick! Many thanks, that's what I need. :-)

(The original tag (e.g. "project") is listed again among the list of related tags but I can live with that and it's probably not worth looking into this further.)

@Mark: I had found out the hard way, about the importance of the blank line in the middle.  :-(
Thanks for the hint.

@Tony: Thanks. Looking again at the code I had posted it seems that the closing markup tag (</$list>) was omitted because the short version of list filter was used? I.e. all in a single line and an extra "/" as the penultimate character.

Thanks again everybody!
Reply all
Reply to author
Forward
0 new messages