Backlinks based on a filter

I have a view template that adds a list of backlinks to each tiddler like so:

<<list-links filter:"[all[current]backlinks[]]">>

I’m trying to extend this to what I’m calling “filter links”. Any tiddler can have a field named filter-links containing a filter that should evaluate to a list of tiddlers that can be considered “linked to” from that tiddler.

For example if a tiddler foo had the field filter-links: [tag[bar]], it can be considered implicitly linked to every tiddler with the tag bar.

What I would like to do is integrate these pseudo-links with my list of backlinks.

With the above example that would mean that any tiddler with the tag bar would list foo as a backlink.

Now I can do this with nested list widgets, but I want to get all the backlinks and “filter backlinks” into a single list so that they can be sorted together. And this has stumped me.

Can anyone help? :slight_smile:

Perhaps something like this will do:

<<list-links filter:"[all[current]backlinks[]] [subfilter{!!filter-links}] +[sort[]]">>
2 Likes

Thank you Eric, though this is not quite what I’m looking for.

While your filter gives me every result of filter-links for the current tiddler, what I want is every tiddler who’s filter-links filter returns the current tiddler.

You have helped me however, since in trying to explain that I have ended up solving my own problem:

[has[filter-links]] :map[all[tiddlers]!is[system]subfilter{!!filter-links}match<..currentTiddler>then<currentTiddler>] +[!is[blank]] [all[current]backlinks[]

This seems to work, but I’m open to more efficient ways to do the same thing.

Thank you for your help as always.

You can simplify it by using :filter run prefix

[has[filter-links]!is[system]]:filter[{!!filter-links}] [<currentTiddler>backlinks[]] +[sort[]unique[]]
2 Likes

Thank you @VikingMage, a much nicer solution than mine.

Oops just realised this doesn’t quite work as it applies the filter to the tiddler with the filter-links field, not the current tiddler. A slight tweak fixes this:

[has[filter-links]] :filter[<..currentTiddler>filter{!!filter-links}] [<currentTiddler>backlinks[]]

what is the [<..currentTiddler>] notation with the double dot prefix inside the filter? I’ve never seen that anywhere.

Have a closer look at: https://tiddlywiki.com/#Named%20Filter%20Run%20Prefix and search for ..currentTiddler at tiddlywiki.com

It is the title of the tiddler outside the filter construction.

1 Like