How to? --- APPEND one tiddler "text" to another? #append

194 views
Skip to first unread message

@TiddlyTweeter

unread,
Apr 4, 2019, 10:35:32 AM4/4/19
to TiddlyWiki
The use case is you create a tiddler and realise it would  be better added to another (not via transclusion, rather, the literal content of "text" is appended to another Tiddler's "text" field.).

Do you know how to do this?

Any tips appreciated.

Best wishes
Josiah

@TiddlyTweeter

unread,
Apr 4, 2019, 10:36:05 AM4/4/19
to TiddlyWiki
Repeat for email ...

Mohammad

unread,
Apr 4, 2019, 11:21:56 AM4/4/19
to TiddlyWiki
Hi Josiah,
 You may like the below macro!


\define append-text(tidTitle, text:"", btnLabel:"Append Text", sep:"<br>")
<$button> $btnLabel$
<$list variable="newText" filter="[<__tidTitle__>get[text]addsuffix<__sep__>addsuffix<__text__>]" >
<$action-setfield $tiddler=<<__tidTitle__>> text=<<newText>> />
</
$list>
</$button>
\end


Examples
Test on Tiddlywiki.com. Create two tiddlers, titles TidA and TidB

Example 1:

<<append-text tidTitle:"Tidb" text:"This is another text">>

Example 2:

<$macrocall $name=append-text tidTitle="TidB" text={{TidA}} sep=" " /
>


Remarks
Note changing a field needs some kind of triggering widgets! So, here I used a button!
  • tidTitle gets the title of tiddler you want to append text to it
  • text the text to be appended
  • btnLabel: the label for button
  • sep: the separator is used when appending text to end of the text of tiddler
If you want to append text of a base tiddler use syntax of example 2.


I hope other people gives their solutions, comment for a better and more concise macro!

--Mohammad


@TiddlyTweeter

unread,
Apr 6, 2019, 5:31:54 AM4/6/19
to tiddl...@googlegroups.com
Thanks for the quick response! Very useful tool!

It works well except that if the target Tiddler (in the example TidB) has an empty text field it won't get appended to. 

Is there a way to get the append working even if the text field is empty?

Many thanks!
Josiah

Mohammad wrote:

 You may like the below macro!


\define append-text(tidTitle, text:"", btnLabel:"Append Text", sep:"<br>")
<$button> $btnLabel$
<$list variable="newText" filter="[<__tidTitle__>get[text]addsuffix<__sep__>addsuffix<__text__>]" >
<$action-setfield $tiddler=<<__tidTitle__>> text=<<newText>> />
</
$list>
</$button>
\end


Examples
Test on Tiddlywiki.com. Create two tiddlers, titles TidA and TidB

Example 1:

<<append-text tidTitle:"TidB" text:"This is another text">>


Example 2:

<$macrocall $name=append-text tidTitle="TidB" text={{TidA}} sep=" " /
>

Mohammad

unread,
Apr 6, 2019, 4:31:06 PM4/6/19
to TiddlyWiki
Hi Josiah!
 This new version works ALSO with empty tiddlers

\define append-text(tidTitle, text:"", btnLabel:"Append Text", sep:"<br>")
<$button> $btnLabel$
<$list variable="newText" filter="[<__tidTitle__>get[text]addsuffix<__sep__>addsuffix<__text__>]" emptyMessage="""<$action-setfield $tiddler=<<__tidTitle__>> text=<<__text__>> />""" >
<$action-setfield $tiddler=<<__tidTitle__>> text=<<newText>> />
</$list>
</$button>
\end

@TiddlyTweeter

unread,
Apr 7, 2019, 1:37:03 AM4/7/19
to TiddlyWiki
Thanks Mohammad!

Very good. And excellent it silently creates the target tiddler if it doesn't exist. Exactly what I needed.

Best wishes
Josiah

Mohammad

unread,
Apr 7, 2019, 2:13:57 AM4/7/19
to TiddlyWiki
Hi Josiah!
 I don't know if this is a bug or a feature, but action-setfield will create tiddler if it does not exist!
Glad you like it!

--Mohammad

Mohammad

unread,
Apr 7, 2019, 2:14:17 AM4/7/19
to TiddlyWiki
Added to Yazd!

--Mohammad

S. S.

unread,
Apr 7, 2019, 5:59:45 AM4/7/19
to TiddlyWiki

Nice macro Mohammad! Works perfectly for a few random tests I made.

Mohammad

unread,
Apr 7, 2019, 6:59:55 AM4/7/19
to TiddlyWiki
Hi S.S.
 I tried to prevent appending text to a NOT existing Tiddler (As Josiah noted above), but seems code gets too complicated!
Seems action-setfiled works to create tiddler if not existed and from programming point of view, I expect to warn and NOT to do that!

--Mohammad

Pit.W.

unread,
Jun 23, 2019, 8:24:58 AM6/23/19
to tiddl...@googlegroups.com

Mohammad,

for more than a year I have been trying to exactly this working.

Thanks a lot!

Pit

--
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 post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/d8d7561c-3e99-4511-a7d2-f75f46c51bdf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


_________________________________________________________________
________________________________________________________
Ihre E-Mail-Postfächer sicher & zentral an einem Ort. Jetzt wechseln und alte E-Mail-Adresse mitnehmen! https://www.eclipso.de


Mohammad

unread,
Jun 23, 2019, 10:21:34 AM6/23/19
to TiddlyWiki
Hello Pit,
 Happy it is working for you! 
This is documented in TWScripts.

Cheers
Mohammad
Reply all
Reply to author
Forward
0 new messages