Display content only if one of two tags match for current tiddler

65 views
Skip to first unread message

Bastian

unread,
Feb 28, 2020, 2:49:18 PM2/28/20
to TiddlyWiki
Hi,

I enhanced the tiddler template where I added some content, that should only be displayed when the current tiddler has one of two tags.
The tags are either "project" or "task".

I have set up this list filter:

<$list filter="[is[current]tag[project] || is[current]tag[task]]"> 
 content for tiddlers with either project or task tag
</$list> 

but it just won't work.
I also tried different positions of the brackets but either the content is displayed for every tiddler or for none.

How can I make a filter for the current tiddler that only triggers if the current tiddler has one of two tags?

Best
Bastian 

Mark S.

unread,
Feb 28, 2020, 3:48:48 PM2/28/20
to TiddlyWiki
The symbols || are not used for "or" in filter runs. There's a new symbol for "else". Try:

[is[current]tag[project]]~[is[current]tag[task]]

This will still run if a project happens to have both "project" and "task", if that's OK.

Good luck!

Eric Shulman

unread,
Feb 28, 2020, 3:53:35 PM2/28/20
to TiddlyWiki
On Friday, February 28, 2020 at 11:49:18 AM UTC-8, Bastian wrote:
I enhanced the tiddler template where I added some content, that should only be displayed when the current tiddler has one of two tags.
The tags are either "project" or "task".  I have set up this list filter:

<$list filter="[is[current]tag[project] || is[current]tag[task]]"> 
 content for tiddlers with either project or task tag
</$list> 

but it just won't work. I also tried different positions of the brackets but either the content is displayed for every tiddler or for none.

Filter syntax doesn't use "||" to represent OR.

Instead, use two space-separated filter "runs", like this:

<$list filter="[is[current]tag[project]] [is[current]tag[task]]"> 

Note that each filter run is a complete filter syntax (including a set of matching outermost square brackets).

enjoy,
-e


Bastian

unread,
Feb 28, 2020, 4:18:18 PM2/28/20
to TiddlyWiki
Dang! That works. Thanks a lot!

TonyM

unread,
Feb 28, 2020, 4:38:55 PM2/28/20
to TiddlyWiki
All,

Untested idea;

The filter 

filter="[is[current]tag[project]] [is[current]tag[task]] +[count[]]" var=matches> 

Could wrap another

filter="[<matches>match[1]]" to only display when only one is true

Or perhaps (again untested)

"[is[current]tag[project]] [is[current]tag[task]] +[count[]] -[[2]]"
OR
"[is[current]tag[project]] [is[current]tag[task]] +[count[]]!match[2]]"

these are common patterns required I would like to find and publish some "best practice"

Regards
Tony
Reply all
Reply to author
Forward
0 new messages