How can I get <$reveal> like functionality based on tags or the composite of fields

45 views
Skip to first unread message

Joshua Baller

unread,
Aug 10, 2019, 6:53:26 PM8/10/19
to TiddlyWiki
Hi,
I have a knowledge base of sorts that I have built into a tiddlywiki. Thousands of tiddlers are being specified in a set of google sheets (each row is a tiddler). The CSVs are converted to JSON and imported, populating tags, fields and the text field. The text field is just: <$transclude tiddler="template_a"/>, the rest of the csv is defining tags or fields. The transcluded template then renders the fields based on the template using a lot of $view and $set calls. Frequently tiddlers may not have certain fields defined, as a result I am using $reveal calls to include or exclude parts of the template (mainly <$reveal type="nomatch" state="!!eff_cs" text=""> like calls)

In all, this is working pretty well. However, I have two particular situations that I have not been able to figure out.

1. I want to reveal a part of the template based on if the tidder doing the transclusion has a particular tag. e.g. IF my_reveal_tag EXISTS_IN_TIDDLER then REVEAL some_text_in_template.

Right now I have been making a tag for a trait in order to enable easy indexing, and seperately making a field with the same information for controlling the template. It would be easier to only define the information in one place.

2. There are also some instances where I want a section of the template to be revealed except when some set of fields are all blank. I tried to use a macro to concatenate the fields and check if the results was an empty string but I couldn't seem to get it to work. e.g. REVEAL some_text_in_template IF field_a != "" OR field_b != "" OR field_c != ""


Any recommendations would be appreciated

TonyM

unread,
Aug 10, 2019, 7:56:34 PM8/10/19
to TiddlyWiki
Joshua

This can all be done with the list widget because it only shows its content If the filter is true. You can also use limit[1] to stop multiple display.

So with this all you need is to obtain the correct filters.

But there is more.....

Regards
Tony

Mark S.

unread,
Aug 10, 2019, 8:00:32 PM8/10/19
to TiddlyWiki
Sometimes it's easier to use the list widget for this kind of thing. Here's your two situations, if I understood them correctly:

<$list filter="[all[current]!has[big]!has[medium]!has[tiny]]">
ALL CLEAR
</$list>

(where big, medium, and tiny are fields)

<$list filter="[all[current]tag[my_reveal_tag]]">
TAG IS REVEALED
</$list>

(where my_reveal_tag is the selecting tag)

Joshua Baller

unread,
Aug 10, 2019, 8:13:20 PM8/10/19
to TiddlyWiki
Thank you, both of you. I was too focused on the Reveal widget and missed how powerful List could be under these circumstances.

Mark, both of those examples worked perfectly. I had toyed with the filters but had missed how to enforce that I only look at tags on the current Tiddler.

Josh
Reply all
Reply to author
Forward
0 new messages