Macro shows conditional contents interactively

103 views
Skip to first unread message

Mohammad

unread,
Sep 16, 2019, 11:16:50 AM9/16/19
to TiddlyWiki
Create a tiddler at tiddlywiki.com with below content

\define macx()
<$set name=x value={{temp}}>
<$list filter="[<x>!match[x]]">
This is a test
<$button 
 set="temp" setTo="x"
 class="tc-btn-invisible tc-tiddlylink">&times;</$button>
</$list>
</$set> 
\end

<<macx>>


Save and see the result!

It shows

This is a test 

On click on x, the content will be disappeared! That is what I want!

Then: I like to reload the wiki (or next time I visit the wiki) and see the This is a test   again!
How it can be done? Note user may use single file wiki or node.js version ($:/state tiddlers are cleared)!

--Mohammad

Anjar

unread,
Sep 16, 2019, 1:55:27 PM9/16/19
to tiddl...@googlegroups.com
Hi,

I guess there are several ways; you could create a tiddler with content "<$action-setfield $tiddler="temp" text="a" />" and tag it "$:/tags/StartupAction" to set the temp-tiddler to "a" at startup. 

But, if I'm not mistaken, you can also create a temporary state tiddler "$:/state/popup/temp" that is not saved?


Best,
Anders

Edit: $:/temp is saved by default, but not $:/state/popup

Mohammad

unread,
Sep 16, 2019, 2:35:01 PM9/16/19
to TiddlyWiki
Hi Andres,
 Seems it works! 
Actually I want to create inside tiddler an inline alert message users can close it (dismiss it)
Something like this

BUT in pure wikitext! (Pure TW script)

--Mohammad


On Monday, September 16, 2019 at 10:25:27 PM UTC+4:30, Anjar wrote:
Hi,

I guess there are several ways; you could create a tiddler with content "<$action-setfield $tiddler="temp" text="a" />" and tag it "$:/tags/StartupAction" to set the temp-field to "a" at startup. 

But, if I'm not mistaken, you can also create a temporary state tiddler "$:/temp/temp" that is not saved?


Best,
Anders

Message has been deleted

Mark S.

unread,
Sep 16, 2019, 3:14:55 PM9/16/19
to TiddlyWiki
$:/temp tiddlers don't seem to disappear in a file TW. Maybe in node?

So this code:

\define macx()
<$list filter="[[$:/temp/mywarning]is[missing]]">
This is a WARNING!
<$button class="tc-btn-invisible tc-tiddlylink">
<$action-setfield $tiddler="$:/temp/mywarning" text="x"/>
 &times;</$button>
</$list>
\end

<<macx>>

and then a tiddler tagged $:/tags/StartupAction with this content:

<$action-deletetiddler $tiddler="$:/temp/mywarning"/>

Mat

unread,
Sep 16, 2019, 3:32:50 PM9/16/19
to TiddlyWiki
Couldn't you just include it as the bottom most tiddler among your default tiddlers?

You could style the tiddler so it appears a bit different if you want, i.e make everything except the text and the close button invisible or a custom close button just next to the text and, again, everything else invisible.

<:-)

Mat

unread,
Sep 16, 2019, 3:42:00 PM9/16/19
to TiddlyWiki
I.e something like this. It could even be a local style block (like here) in the very tiddler.

<style>
[data-tiddler-title="MyTid"] {
 background
:transparent;
 border
:0;
}
[data-tiddler-title="MyTid"] .tc-tiddler-title {
 display
:none;
}
/* etc */
</style>

<:-)
Message has been deleted

Anjar

unread,
Sep 16, 2019, 3:50:27 PM9/16/19
to TiddlyWiki
You're right, I'm sorry. I just read an old thread where it was stated, and there seems to have been some confusion: https://github.com/Jermolene/TiddlyWiki5/issues/1971#issuecomment-144122370

Alternatively, one can change which tiddlers that are saved: http://tobibeer.github.io/tb5/#States%20And%20Temporary%20Tiddlers

I'll update my answers. However, the $:/state/popup is not saved so I gues that should be used instead of $:/temp

Best,
Anders

(Reposted, deleted by accident)

Mohammad

unread,
Sep 16, 2019, 4:08:12 PM9/16/19
to tiddl...@googlegroups.com
Thanks Mark!
I would also add a statTid as input param to be able to have several alert in different tiddlers

--Mohammad

Added to TW-Scripts!

PMario

unread,
Sep 19, 2019, 3:30:15 AM9/19/19
to TiddlyWiki
Hi,

$:/state/xxxx tiddlers are saved!

IMO you could use $:/state/popup/ prefixed state tiddlers. They are not saved to the file or node version.

-m

PMario

unread,
Sep 19, 2019, 3:32:10 AM9/19/19
to TiddlyWiki
uups,
I did reply to a cached version of the topic. Haven't seen, that there are already some responses that seem to work.

-m

Mohammad

unread,
Sep 19, 2019, 3:49:38 AM9/19/19
to TiddlyWiki
Okay Mario!
 So if we use $:/state/popup/ prefixed state tiddlers then there is no need for startup action here right?

-- Mohammad

PMario

unread,
Sep 19, 2019, 3:56:27 AM9/19/19
to TiddlyWiki
On Thursday, September 19, 2019 at 9:49:38 AM UTC+2, Mohammad wrote:
Okay Mario!
 So if we use $:/state/popup/ prefixed state tiddlers then there is no need for startup action here right?

I didn't test it, but I think it should work, if you reload the page or click "home" button.

-m

Mohammad

unread,
Sep 19, 2019, 5:07:00 AM9/19/19
to TiddlyWiki
Thanks!

Added to TW-Scripts
Reply all
Reply to author
Forward
0 new messages