Create Save and close in one click ?

123 views
Skip to first unread message

paulgilbert2000

unread,
Jun 6, 2021, 3:43:25 PM6/6/21
to TiddlyWiki

Hi,

is there a way to have a button  create a new tiddler ,save it  and close it all in one click?

Eric Shulman

unread,
Jun 6, 2021, 4:14:27 PM6/6/21
to TiddlyWiki
On Sunday, June 6, 2021 at 12:43:25 PM UTC-7 Mohamed...@hotmail.com wrote:
is there a way to have a button  create a new tiddler ,save it  and close it all in one click?

You can create a tiddler and set field values without ever opening it by using $action-setfield, like this:

<$button> click me
   <$action-setfield $tiddler="SomethingNew" text="yabba dabba doo!" tags="foo bar baz" caption="this is a caption" somefield="argle bargle" />
</$button>
 
-e

Eric Shulman

unread,
Jun 6, 2021, 4:18:47 PM6/6/21
to TiddlyWiki
addendum:

If you want to create new tiddlers with automatic numbering if the tiddler already exists, use $action-createtiddler, like this:

<$button> click me
   <$action-createtiddler $basetitle="SomethingNew" text="yabba dabba doo!" tags="foo bar baz" caption="this is a caption" somefield="argle bargle" />
</$button>

-e

TW Tones

unread,
Jun 8, 2021, 6:49:34 PM6/8/21
to TiddlyWiki
Mohamed - See here perhaps the  EditButtons plugin is what you need?

Tones

paulgilbert2000

unread,
Jun 8, 2021, 10:03:17 PM6/8/21
to TiddlyWiki
Thank you Eric,

One more thing if possible , the field part somefield, i need to transclude a value there with spaces

somefield={{!!title}}

and i cant add brackets , because this turns it into a string [[{{!!title}}]]

Is there any way to insert the value inclosed in brackets ?

Eric Shulman

unread,
Jun 9, 2021, 12:23:01 AM6/9/21
to TiddlyWiki
On Tuesday, June 8, 2021 at 7:03:17 PM UTC-7 Mohamed...@hotmail.com wrote:
One more thing if possible , the field part somefield, i need to transclude a value there with spaces
somefield={{!!title}}
and i cant add brackets , because this turns it into a string [[{{!!title}}]]
Is there any way to insert the value enclosed in brackets ?

So... let's say you have a title of "Foo Bar Baz" (i.e., text containing spaces).  Then, when you create a new tiddler using somefield={{!!title}}, the resulting value of somefield will still be "Foo Bar Baz" (i.e., a single text value containing spaces).  For almost all purposes, this will be sufficient, and subsequent references to {{!!somefield}} will still result as a single text value containing spaces.  Nonetheless, it still possible to save the field value including added brackets, so that it will be stored as "[[Foo Bar Baz]]".  Here's one method for adding the brackets:

<$button> click me
   <$vars lb="[[" rb="]]">
   <$action-createtiddler $basetitle="SomethingNew" text="yabba dabba doo!" tags="foo bar baz" caption="this is a caption" somefield={{{ [{!!title}addprefix<lb>addsuffix<rb>] }}} />
   </$vars>
</$button>

Notes:
* The $vars defines two variables that contain the literal "[[" and "]]" text
* The somefield parameter value is then assembled using "filtered transclusion" to add the brackets before and after the {!!title} value.
* The $vars is needed because you can't use literal square brackets as text within the filter syntax, since they would be interpreted as part of the filter syntax itself (i.e., you can't write ...addprefix[[[]... or ...addsuffix[]]]...)

Another way to achieve this is to use macros instead of $vars to define the lb and rb variables, like this:
\define lb() [[
\define rb() ]]

<$button> click me
   <$action-createtiddler $basetitle="SomethingNew" text="yabba dabba doo!" tags="foo bar baz" caption="this is a caption" somefield={{{ [{!!title}addprefix<lb>addsuffix<rb>] }}} />
</$button>

enjoy,
-e

paulgilbert2000

unread,
Jun 10, 2021, 6:04:53 PM6/10/21
to TiddlyWiki
Thanks Eric,

works very well:)

@ tones thanks for the suggestion , was not exactly what i am looking for , but very good to know about, will def be using too !!

thank again every one

paulgilbert2000

unread,
Jun 12, 2021, 2:14:07 PM6/12/21
to TiddlyWiki
Hi again ,

can this work for drop downs as well ? so if i have something like this


 <$select
field="blocker"…>
<$list filter='[!is[system]!status[completed]tag[task]sort[title]]'>
<option><$view field= 'title'/></option>
</$list>
</$select>

can i get the value chosen from the drop list to populate with brackets in the "blocker field "  ?

Eric Shulman

unread,
Jun 12, 2021, 3:11:39 PM6/12/21
to TiddlyWiki
On Saturday, June 12, 2021 at 11:14:07 AM UTC-7 Mohamed...@hotmail.com wrote:
 <$select
field="blocker"…>
<$list filter='[!is[system]!status[completed]tag[task]sort[title]]'>
<option><$view field= 'title'/></option>
</$list>
</$select>
can i get the value chosen from the drop list to populate with brackets in the "blocker field "  ?

Try this: 
<$vars lb="[[" rb="]]">
<$select field="blocker" default="select a task...">
   <option disabled>select a task...</option>
   <$list filter='[!is[system]!status[completed]tag[task]sort[title]]'>
      <option value={{{ [{!!title}addprefix<lb>addsuffix<rb>] }}}>
         <$view field= 'title'/>
      </option>
   </$list>
</$select>
</$vars>

Note:
* The $vars defines two variables that contain the literal "[[" and "]]" text
* The $vars is needed because you can't use literal square brackets as text within the filter syntax, since they would be interpreted as part of the filter syntax itself (i.e., you can't write ...addprefix[[[]... or ...addsuffix[]]]...)
* The option entries use the value=... parameter with filtered transclusion syntax to add the bracket prefix and suffix around the selected value

enjoy,
-e
Reply all
Reply to author
Forward
0 new messages