Rendering Multiple Tags

62 views
Skip to first unread message

Taylor Jensen

unread,
Sep 7, 2020, 10:00:06 PM9/7/20
to TiddlyWiki
What I'd like to do is create a list formatted "Title - tags of that tiddler"

So we have the tag template `{{Transclusion||$:/core/ui/TagTemplate}}` that lets me get "Transclusion" in nice tag pill form.

But when I do:

`<$list filter="[tag[mytag]]">
<li><$link to={{!!title}}/>{{!!tags||$:/core/ui/TagTemplate}}</li>
</$list>
`

all I get is "Title - that title but in pill form". The template can't use anything but the title of a tiddler. But getting all the tags in pill form is clearly generatable since it's generated at the top of every tiddler. Is there a way I can access that and use it in lists?

Eric Shulman

unread,
Sep 7, 2020, 10:30:34 PM9/7/20
to tiddl...@googlegroups.com
The tags field is a list of tags, not a single value.
To show a tag pill for each tag of a given tiddler, you need to use a second $list widget to display one tag at a time.
Note also that the default parameter value for $link is the current tiddler, so you don't need to specify to={{!!title}}

Thus:
<$list filter="[tag[mytag]]">
   
<li><$link/><$list filter={{!!tags}}>{{||$:/core/ui/TagTemplate}}</$list></li>
</$list>

enjoy,
-e

TW Tones

unread,
Sep 7, 2020, 11:55:05 PM9/7/20
to TiddlyWiki
Also,

Remember there is the tag macro
<<tag tagname>>

But inside a list you may use
<$macrocall $name=tag tag=<<currentTiddler>> />

Eric's solution is especially good if you want to add additional content along with the listed tag pills.

For example add this in before the `</li>` tag
<$text text={{{ [tag<currentTiddler>count[]] }}}/>
Which returns the number of tiddlers tagged by that tag

Regards
Tones


Regards
Tony

Taylor Jensen

unread,
Sep 7, 2020, 11:59:41 PM9/7/20
to TiddlyWiki
This is perfect, I knew I needed to iterate I just didn't know how to do it.

Thank you!
Reply all
Reply to author
Forward
0 new messages