Changing title displayed when using the list macro

222 views
Skip to first unread message

Jack Baty

unread,
Jan 8, 2019, 10:51:59 AM1/8/19
to TiddlyWiki
I have begun creating tiddlers for words I find interesting. Each tiddler's title is something like "Word: chiaroscuro" and I tag them with "Word"

I am trying to display a comma-delimited list of tiddlers tagged with "Word" but would like each link to not include the "Word: " prefix, yet still link to the appropriate tiddler.

This is as close as I've come:

<$list filter='[tag[Word]butlast[]removeprefix[Word: ]]'><$link><$view field="title"/></$link>,</$list>
<$list filter='[tag[Word]last[]removeprefix[Word: ]]'><$link><$view field="title"/></$link></$list>

This produces the comma-delimited list and link text the way I want, but the links don't work because they don't include the "real" title. (e.g. "chiaroscuro" rather than "Word: chiaroscuro")

Is there a better approach to this? I've tried adding "Word: " back into the link in a few ways but have been unsuccessful in making the links work.

Thanks,

Jack

Mark S.

unread,
Jan 8, 2019, 11:19:46 AM1/8/19
to TiddlyWiki
Ok, this will do what you want:

<$list filter='[tag[Word]]' >
<$list filter='[all[current]removeprefix[Word: ]]' variable="word"><$link><
<word>></$link>,</$list>
</$list>

But the big question is, why are you overloading the title? Making it do even more work than it is already doing (it's a title field, a visibility field, and an ID field) ? Wouldn't it be easier to leave off "Word:" and then add "Word: " back in with whatever reporting function you want? It's easy to add stuff in TW, but, as you have seen, it's harder to subtract stuff. 

Have fun
-- Mark

Eric Shulman

unread,
Jan 8, 2019, 11:42:10 AM1/8/19
to TiddlyWiki
On Tuesday, January 8, 2019 at 7:51:59 AM UTC-8, Jack Baty wrote:
I am trying to display a comma-delimited list of tiddlers tagged with "Word" but would like each link to not include the "Word: " prefix, yet still link to the appropriate tiddler.
<$list filter='[tag[Word]butlast[]removeprefix[Word: ]]'><$link><$view field="title"/></$link>,</$list>
<$list filter='[tag[Word]last[]removeprefix[Word: ]]'><$link><$view field="title"/></$link></$list>


Instead of removing the "Word:" prefix in the main <$list> widget, just match the desired titles as-is, so that the <$link> widget will get the correct tiddler title for *navigation* purposes.

Then, separately apply the removeprefix["Word:" ] to the currentTiddler using an 'inline filter' (the triple curly brace syntax) to produce the desired text for *display* purposes.

Something like this:
<$list filter='[tag[Word]butlast[]]'><$link>{{{ [<currentTiddler>removeprefix[Word: ]] }}}</$link>,</$list>
<$list filter='[tag[Word]last[]]'>   <$link>{{{ [<currentTiddler>removeprefix[Word: ]] }}}</$link> </$list>

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

Jack Baty

unread,
Jan 8, 2019, 11:43:31 AM1/8/19
to TiddlyWiki
This works perfectly, thanks!

> But the big question is, why are you overloading the title?

Good question! I've found that I prefer seeing the prefix in things like the sidebar (e.g. on the "Recent" tab) and in search results. I can search "Word:" and the results are nicely filtered for me. The only place that I don't want to see the prefix is when collecting them in a single tiddler. More often than not I want the prefix, so removing it doesn't need to happen nearly as often as adding it would.

I'm inexperienced with TiddlyWiki so I'm sure there are other approaches that might work.

Jack Baty

unread,
Jan 8, 2019, 11:54:30 AM1/8/19
to TiddlyWiki


On Tuesday, January 8, 2019 at 11:42:10 AM UTC-5, Eric Shulman wrote:
Instead of removing the "Word:" prefix in the main <$list> widget, just match the desired titles as-is, so that the <$link> widget will get the correct tiddler title for *navigation* purposes.

Then, separately apply the removeprefix["Word:" ] to the currentTiddler using an 'inline filter' (the triple curly brace syntax) to produce the desired text for *display* purposes.

Something like this:
<$list filter='[tag[Word]butlast[]]'><$link>{{{ [<currentTiddler>removeprefix[Word: ]] }}}</$link>,</$list>
<$list filter='[tag[Word]last[]]'>   <$link>{{{ [<currentTiddler>removeprefix[Word: ]] }}}</$link> </$list>

Thanks Eric, this looks like it could be a nice, clean solution. Unfortunately, for me, the generated links do not include "Word: " so do not link to the correct tiddler.

Eric Shulman

unread,
Jan 8, 2019, 12:19:56 PM1/8/19
to tiddl...@googlegroups.com
The problem is that, because the title contains a space, and the result of the 'inline filter' is a *list*, the output is automatically enclosed with doubled square brackets, which renders a "link-within-a-link".  To avoid this, the display output can use the <$text> widget to produce 'pure' text, like this:

<$list filter='[tag[word]butlast[]]'><$link><$text text={{{ [<currentTiddler>removeprefix[Word: ]] }}}/></$link>,</$list>
<$list filter='[tag[word]last[]]'>   <$link><$text text={{{ [
<currentTiddler>removeprefix[Word: ]] }}}/></$link> </$list>

This should work now.

enjoy,
-e


Jack Baty

unread,
Jan 8, 2019, 12:24:23 PM1/8/19
to TiddlyWiki
Eric,

This should work now.

It does indeed, thank you! I have a lot to learn.

S. S.

unread,
Jan 12, 2019, 4:28:53 AM1/12/19
to TiddlyWiki


Glad the problem was solved so elegantly!

Since I have a similar interest of making tiddlers of words I find interesting, I will take the opportunity to share a macro I use to easily look up the meanings of any special words.

I make the New Interesting Words tiddler using a Template, and the template contains the line:
<<dictionary {{!!title}}>>
The tiddler's title is simply the word itself, for example: avarice

In your case, the template line could be replaced with:

<$macrocall $name="dictionary" word={{{ [<currentTiddler>removeprefix[Word: ]] }}} />

In a tiddler tagged with $:/tags/Macro , I have defined the dictionary macro as follows:

\define dataLinkCreator(data-file index word)
\rules except wikilink
<$wikify name="input" text="{{$data-file$##$index$}}$word$">
<a href=<<input>> target="_blank">$index$</a>
</
$wikify>
\end

\define dictionary(word datafile:"$:/_data/dictionaryLinks")
<small>
<$list filter="[[$datafile$]indexes[]]" variable="index">
<$macrocall $name="dataLinkCreator" data-file="$datafile$" index=<<index>> word=$word$/>
</$list>
</
small>
\end



In a tiddler titled: $:/_data/dictionaryLinks
And with its Content Type set to : application/x-tiddler-dictionary
I have the following:


Thus, if you had a tiddler named: Word: avarice
And that tiddler had in its text: <$macrocall $name="dictionary" word={{{ [<currentTiddler>removeprefix[Word: ]] }}} />

This line of links would appear in the tiddler:


Of course you could tweak the macro to do the removal of the prefix, so that you can simply use: <<dictionary {{!!title}}>>
However that would mean the macro could not be used elsewhere for a set of links for a word, like <<dictionary tiddlywiki>>

Hope you find this useful.

Jack Baty

unread,
Jan 12, 2019, 7:41:52 AM1/12/19
to TiddlyWiki
This is terrific and works like a charm, thanks for sharing it!

Jack

Mohammad

unread,
Jan 12, 2019, 12:52:05 PM1/12/19
to TiddlyWiki
Hi S. S.,

This is a wonderful piece of work.
I appreciate if you could publish this as a small plugin.
It can accept a word as an input parameter and return that line of links to dictionary sites.

Cheers
Mohammad

S. S.

unread,
Jan 12, 2019, 1:36:01 PM1/12/19
to TiddlyWiki
Thanks for the compliment Mohammad!

At some point I might do a tutorial for tiddlywiki.com on how to make it and how it works. For such simple solutions I believe users are better off using copy and paste - it allows them to be more in control of their work and the names & locations of their tiddlers, as well as more comfortable making modifications to suit their needs.

Just as a side note unrelated to TiddlyWiki, but on the topic of using online dictionaries for looking up words. Maybe some readers here might benefit from this tip.

I read a lot, and often have to look up dozens of words a day. In a browser like Firefox, if one makes this set of bookmarks (perhaps in a bookmarks folder named "Search templates"), it makes life so much easier:

Name: Dictionary Reference.com
Location: https://dictionary.com/browse/%s
Keyword: d

Name: Dictionary Webster
Location: http://www.webster-dictionary.org/definition/%s
Keyword: dd

Name: Thesaurus.com
Location: http://thesaurus.com/browse/%s
Keyword: t

Name: Etymology Online
Location: http://www.etymonline.com/index.php?term=%s
Keyword: e

And so on.

Then to look up a word, in the browser bar, you just type: the keyword, followed by the word you want to look up.

So to look up the word "avarice" in any of those places, in the browser's bar where you would normally type: http://..... etc. - you just type any one of the following lines:
d avarice
dd avarice
t avarice
e avarice
(And so on.)

It is extremely fast and convenient and soon becomes second nature.

Mohammad

unread,
Jan 12, 2019, 2:28:07 PM1/12/19
to TiddlyWiki
Good points!
Seems only work on FF.

Thank you

Mohammad

unread,
Jan 12, 2019, 2:48:22 PM1/12/19
to TiddlyWiki
I found how it works in Chrome.
Edit SearchEngine, that is the key.

--Mohammad

TonyM

unread,
Jan 12, 2019, 9:48:52 PM1/12/19
to TiddlyWiki
Nice tip, thanks
Reply all
Reply to author
Forward
0 new messages