Append text to body of all tiddlers that match a certain tag

80 views
Skip to first unread message

Damon Pritchett

unread,
Dec 11, 2018, 7:02:11 PM12/11/18
to TiddlyWiki
Hello,

I'm looking for a way to append one or more lines of text to the body of all tiddlers that are tagged with a specified tag and only those tiddlers. I have several hundred tiddlers that are all tagged with a certain tag value. I would like to append a backlinks line at the end of each of these so that I can see what other tiddlers reference them. Is there an easy way of doing this?

Thanks,

Damon Pritchett

Mark S.

unread,
Dec 11, 2018, 7:38:17 PM12/11/18
to TiddlyWiki
Physically appending the items would mean that you would then have to change them (probably manually) every time your tiddlers changed. But you could use a view template.

Make a tiddler and tag it with $:/tags/ViewTemplate with the following contents:

<$list filter="[all[current]tag[HelloThere]backlinks[]limit[1]]" variable="dummy">

!!! Backlinks
<
<list-links "[all[current]backlinks[]]">>

</$list>

But change tag[HelloThere] to whatever your tag name is.

This should list links to the respective tiddlers at the bottom of the tiddlers that have the desired tag.

Be sure to make a make a backup before trying this, in case I've made some horrible error!

Also, be aware that if you just want to see the backlinks occasionally, you can click on the "info" button from the drop-down menu on every tiddler. From the set of tabs that appears you can pick "References"  to see a listing of tiddlers that link to the current tiddler.

-- Mark

Damon Pritchett

unread,
Dec 11, 2018, 8:26:52 PM12/11/18
to TiddlyWiki
Hi Mark,

Thanks very much. That nearly did the trick, but it was very selective. Not every tiddler with the given tag was modified. I didn't check all 1800 of them, but of the ones I did check, only a small fraction were changed. It did exactly what I wanted otherwise.

Damon

Mark S.

unread,
Dec 11, 2018, 9:02:33 PM12/11/18
to TiddlyWiki
It only displays if there are backlinks. If there are no backlinks, then there will be no display.

Damon Pritchett

unread,
Dec 11, 2018, 9:23:20 PM12/11/18
to TiddlyWiki
Ah, ok. Could you tell me what in the code prevents it from showing if there are no backlinks? Also, is there a way to format the output to match the format of the tiddler?

Damon

Diego Mesa

unread,
Dec 11, 2018, 9:47:07 PM12/11/18
to TiddlyWiki
Hey Damon,

The part that prevents it from showing when there aren't any backlinks is the ListWidget's filter attribute - the same part that shows it if there are backlinks. In other words, if that filter is empty (no backlinks) then nothing inside the list widget gets done. If the filter is NOT empty (meaning there ARE backlinks), then the list widget goes ahead and does stuff.

For example, if you go to tiddlywiki.com make a new tiddler and type:


<$list filter="[tag[HelloThere]]">

</$list>

you should see all of the tiddlers tagged with HelloThere. But if you type:

<$list filter="[tag[SomeNonsenseTag]]">

</$list>

you would see nothing! 

Mark S.

unread,
Dec 11, 2018, 9:48:55 PM12/11/18
to TiddlyWiki
Change the first filter to

[all[current]tag[HelloThere]]

(but with your tag) and then it should always display the "Backlinks" title.

As for the format, I'm not sure what you mean. I used the list-links macro (https://tiddlywiki.com/#list-links%20Macro) to display the actual links. That was the quickest, easiest way to display the items. The list-links macro can take a class, to help customize the look. But you can "roll your own" by replacing the list-links with the list widget, using the same filter as used with the list-links macro.

See https://tiddlywiki.com/#ListWidget for more information about using the list widget.

HTH
-- Mark

Damon Pritchett

unread,
Dec 11, 2018, 10:01:34 PM12/11/18
to TiddlyWiki
Duh! Thanks for the reminder.

Damon Pritchett

unread,
Dec 11, 2018, 10:02:35 PM12/11/18
to TiddlyWiki
Thanks very much. As far as formatting goes, I was really meaning the font of the "Backlinks" title and I've got that now.

Damon

TonyM

unread,
Dec 12, 2018, 10:46:59 PM12/12/18
to TiddlyWiki
Remember also, what ever your filter you can allways use the emptyMessage for when there is not results

<$list filter="[tag[SomeNonsenseTag]]" emptyMessage="No Result">

</$list>

Or you could add a second filter with the new else character ~

<$list filter="[tag[SomeNonsenseTag]] ~[filterifnull]" >

</$list>



Regards
Tony
Reply all
Reply to author
Forward
0 new messages