Show Tag Tiddlers of Current Tiddler marked with certain Tag

86 views
Skip to first unread message

Jake

unread,
Jul 18, 2020, 2:47:44 AM7/18/20
to tiddl...@googlegroups.com
Well, the title says it all. Very simple one.

E.g. if I have a small movie base and I have "genre" tags like "Action", "Drama", "Comedy", etc. and I marked all those tags with "genre" tag.

And now I want to show them as clickable Tiddlers in the text field of a current Tiddler like:

Genre: [[....]], [[...]], [[...]]

As I understand $view won't do, so I have to use $list and probably use a filter [tags[]tag[genre]] or smth, but I'm lost in syntax once again...

Mat

unread,
Jul 18, 2020, 3:59:53 AM7/18/20
to TiddlyWiki
You may be interested in list-links-inline

Otherwise;

<$list filter="[tag[genre]]"><$link/>, </$list>

(A problem here is that you'll get a comma also after the last title.)

<:-)

Jake

unread,
Jul 18, 2020, 4:29:12 AM7/18/20
to tiddl...@googlegroups.com
No-no-no... that will just show all the Tag Tiddlers tagged "genre" and I know how to do that already :), but I want to show tags only if they are present in the current tiddler
That is if current tiddler has only 1 genre tag "Comedy", I want to show only 1 clickable tiddler tag [[Comedy]]. If if has Action and Drama - only those, etc. Not the list of all the genre tags present in wiki.

Currently I have something like
<$list filter="[title{!!title}tag[Action]then[Action]]"> <$link/>, </$list>
<$list filter="[title{!!title}tag[Comedy]then[Comedy]]"> <$link/>, </$list>
<$list filter="[title{!!title}tag[Drama]then[Drama]]"> <$link/>, </$list> 
etc. listing all genres.

but I'm 100% sure there is a much shorter and easier way to do that. :)

Mat

unread,
Jul 18, 2020, 5:19:18 AM7/18/20
to TiddlyWiki
OK, maybe:

<$vars curr=<<currentTiddler>>>
<$list filter="[tag[genre]]">
<$list filter="[
<curr>tag<currentTiddler>]"><$link/>, </$list>
</$list>
</$vars>


<:-)

Eric Shulman

unread,
Jul 18, 2020, 5:24:28 AM7/18/20
to tiddl...@googlegroups.com
On Friday, July 17, 2020 at 11:47:44 PM UTC-7, Jake wrote:
Well, the title says it all. Very simple one.
E.g. if I have a small movie base and I have "genre" tags like "Action", "Drama", "Comedy", etc. and I marked all those tags with "genre" tag.
And now I want to show them as clickable Tiddlers in the text field of a current Tiddler like:
Genre: [[....]], [[...]], [[...]]

You can use nested $list widgets, like this:

Genre:
<$list filter="[tag[genre]]" variable="genre">
   
<$list filter="[<currentTiddler>tag<genre>]">
     
<$link to=<<genre>>/>,
   </
$list>
</$list>

The outer $list gets each tiddler tagged with genre.
The inner $list checks if the current tiddler has that genre as a tag

OR...

<$list filter="[<currentTiddler>enlist{!!tags}]" variable="thistag">
   <$list filter="[
<thistag>tag[genre]]">
      <$link to=<
<thistag>>/>,
   </$list>
</$list>

The outer $list gets all tags for the current tiddler
The inner $list checks each of those tags to see if it is a genre

enjoy,
-e




Jake

unread,
Jul 18, 2020, 5:24:50 AM7/18/20
to TiddlyWiki
Errmm... Nope.... :)
As a result I get current tiddler title shown 9 times... :)

Jake

unread,
Jul 18, 2020, 5:32:08 AM7/18/20
to tiddl...@googlegroups.com
 
You can use nested $list widgets, like this:

Genre:
<$list filter="[tag[genre]]" variable="genre">
   
<$list filter="[<currentTiddler>tag<genre>]">
     
<$link to=<<genre>>/>,
   </
$list>
</$list>

The outer $list gets each tiddler tagged with genre.
The inner $list checks if the current tiddler has that genre as a tag
 
Yay! This one works!.. now I need some time to process what is happenning inside... :) 

| ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄|  
| Thanks a lot, Eric! |
|____________|
(\__/) ||
(•ㅅ•) ||
/   づ  



Once again, I doubt that I could have figured it out by myself...

Mat

unread,
Jul 18, 2020, 5:35:47 AM7/18/20
to TiddlyWiki
Jake wrote:
Errmm... Nope.... :)
As a result I get current tiddler title shown 9 times... :)

Doh, my bad, sorry for that. Anyway, Mr. E saves the day as usual ;-)

<:-) 

Jake

unread,
Jul 18, 2020, 5:52:28 AM7/18/20
to TiddlyWiki
OR...

<$list filter="[<currentTiddler>enlist{!!tags}]" variable="thistag">
   <$list filter="[
<thistag>tag[genre]]">
      <$link to=<
<thistag>>/>,
   </$list>
</$list>

The outer $list gets all tags for the current tiddler
The inner $list checks each of those tags to see if it is a genre

Yep! The second one also works, though the 1st one is a bit easier to understand (since I haven't used "enlist" yet :) ) 

PMario

unread,
Jul 18, 2020, 6:04:34 AM7/18/20
to TiddlyWiki
Hi Jake,

I think the shortest and most performant filter is: [enlist{!!tags}]+[tag[genre]]

It lists the tags of the current tiddler and then looks, if it has a tag "genre"

There are 2 lists:

The first will give you a comma separated list.

<$list filter="[enlist{!!tags}]+[tag[genre]]"><$link/>, </$list>

The second will give you tag pills, that open a drop down list, if you click them.

<$list filter="[enlist{!!tags}]+[tag[genre]]"><<tag>></$list>

have fun!
mario


Mat

unread,
Jul 18, 2020, 6:25:42 AM7/18/20
to TiddlyWiki
[enlist{!!tags}]+[tag[genre]]

Nit pick but even shorter:

[enlist{!!tags}tag[genre]] 

<:-)

PMario

unread,
Jul 18, 2020, 6:34:58 AM7/18/20
to TiddlyWiki
You are right ;)
-m

Jake

unread,
Jul 18, 2020, 6:51:46 AM7/18/20
to TiddlyWiki
I think the shortest and most performant filter is: [enlist{!!tags}]+[tag[genre]]

It lists the tags of the current tiddler and then looks, if it has a tag "genre"
There are 2 lists:
The first will give you a comma separated list.
<$list filter="[enlist{!!tags}]+[tag[genre]]"><$link/>, </$list>
The second will give you tag pills, that open a drop down list, if you click them.
<$list filter="[enlist{!!tags}]+[tag[genre]]"><<tag>></$list>

 
[enlist{!!tags}]+[tag[genre]]
Nit pick but even shorter:
[enlist{!!tags}tag[genre]] 

Yes! It works! I knew this should be short! :)

 As I understand $view won't do, so I have to use $list and probably use a filter [tags[]tag[genre]] or smth, but I'm lost in syntax once again...  

I think I'll stick with this one:
<$list filter="[enlist{!!tags}tag[genre]]"><$link/>, </$list>

Should study this "enlist" though...

Thanks Mario & Mat!

TW Tones

unread,
Jul 18, 2020, 8:08:13 AM7/18/20
to TiddlyWiki
Fyi enlist

Enlist is like list but treats the values as titles. So enlist{!!tags} treats the contents of the tags field as titles so it would respect spaces in titles and kind of wrap them in [[square brackets]] or ensure they are treated as titles.

Regards
Tony

Reply all
Reply to author
Forward
0 new messages