Select among three tiddlers with priority

52 views
Skip to first unread message

Mohammad

unread,
Dec 4, 2019, 1:28:21 AM12/4/19
to TiddlyWiki
How to select among three tiddlers in below priority?

- if tid1, tid2, and tid3 are existed then return tid1
-if tid2, and tid3 are existed return tid2
-if tid1 and tid2 are NOT existed then return tid3

Note the first two tiddlers come from a filter result and we don not know their name in advance like
  • [tag[a]] for tid1
  • [tag[b]] for tid2
I thought the below code may work, what do you propose?

<$list filter="[tag[a]] [tag[b]] +[limit[1]]" emptyMessage="tid3">
<
<currentTiddler>>
</$list>


--Mohammad

TonyM

unread,
Dec 4, 2019, 1:38:49 AM12/4/19
to TiddlyWiki
Mohammad,

Am I correct restating your requirement that "given three tiddlers select the first one you find?"

I would think this works, if not your own example
<$list filter="[tag[a]] [tag[b]] [[tid3]] +[limit[1]]">
<<currentTiddler>>
</$list>

Tony

Mohammad

unread,
Dec 4, 2019, 2:01:50 AM12/4/19
to TiddlyWiki
Yes, seems your solution also works!

I am trying to use this for tiddler overloading like the one is found for shadow tiddlers!

So, tid2 is required to overload if tid1 exist! If none exist TW should use a default tiddler called tid3 here!


One use case:

  1. Display a tiddler using template tid2 (the one tagged with b)
  2. If user supplied its own template use user template here is tid1 (the one tagged with a)
  3. If not supplied tid1 nor tid2 use a default template called tid3


--Mohammad 

TonyM

unread,
Dec 4, 2019, 3:10:29 AM12/4/19
to TiddlyWiki
Mohammad,

The word is perhaps overiding rather than overloading.

There are a number way to do this that I use for this. I will share some.

Tony

Xavier Cazin

unread,
Dec 4, 2019, 4:42:22 AM12/4/19
to tiddl...@googlegroups.com
Hi Mohammad,

For your use case, here is a typical use of the ~ operator (aka "else") on filter runs :

<$list variable=template filter="[tag[a]] ~[tag[b]] ~[[tid3]]">
<$transclude mode=block tiddler=<<template>> />
</$list>

Best regards,
Xavier.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/b9e4d7a7-e8d2-43b1-9e56-60ddf30b263c%40googlegroups.com.

Mohammad

unread,
Dec 4, 2019, 9:52:50 AM12/4/19
to TiddlyWiki
Yep, this is a smart solution and more semantic than my solution!
Thanks Xavier!

--Mohammad


On Wednesday, December 4, 2019 at 1:12:22 PM UTC+3:30, Xavier wrote:
Hi Mohammad,

For your use case, here is a typical use of the ~ operator (aka "else") on filter runs :

<$list variable=template filter="[tag[a]] ~[tag[b]] ~[[tid3]]">
<$transclude mode=block tiddler=<<template>> />
</$list>

Best regards,
Xavier.

On Wed, Dec 4, 2019 at 8:02 AM Mohammad <mohamma...@gmail.com> wrote:
Yes, seems your solution also works!

I am trying to use this for tiddler overloading like the one is found for shadow tiddlers!

So, tid2 is required to overload if tid1 exist! If none exist TW should use a default tiddler called tid3 here!


One use case:

  1. Display a tiddler using template tid2 (the one tagged with b)
  2. If user supplied its own template use user template here is tid1 (the one tagged with a)
  3. If not supplied tid1 nor tid2 use a default template called tid3


--Mohammad 

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages