button to create tiddler tagged with currentTiddler title, author field variable

81 views
Skip to first unread message

Sapphireslinger

unread,
Oct 19, 2020, 10:30:49 AM10/19/20
to TiddlyWiki
When I hit the "New Quote" button embedded in all my book tiddlers, I want to get a new tiddler tagged with (1) the title of the currentTiddler, (2) the variable contained in the author field and (3) the word "quote". 

I searched and tried all kinds of permutations for 2 hours but can't figure it out. The version below makes a tag for every word of the tiddler title and the author field, besides creating a weird field. :P 

<$list filter="[<currentTiddler>prefix[Book -]]">

<$button>
<$action-sendmessage $message="tm-new-tiddler" title=<<now "YYYY.0MM.0DD.0hh0mm0ss QUOTE - ">> tags= <<currentTiddler>>  <<author>> quote />
New Quote
</$button>

   <$list filter="[tag<currentTiddler>!sort[title]]">
   <h2><$link><$transclude field="title" mode="block"/></$link></h2>

   <$transclude field="text" mode="block"/>
   </$list>
</$list>

Eric Shulman

unread,
Oct 19, 2020, 11:12:15 AM10/19/20
to TiddlyWiki
On Monday, October 19, 2020 at 7:30:49 AM UTC-7, Sapphireslinger wrote:
When I hit the "New Quote" button embedded in all my book tiddlers, I want to get a new tiddler tagged with (1) the title of the currentTiddler, (2) the variable contained in the author field and (3) the word "quote". 
I searched and tried all kinds of permutations for 2 hours but can't figure it out. The version below makes a tag for every word of the tiddler title and the author field, besides creating a weird field. :P 

Give this a try:
\define newtags() [[$(currentTiddler)$]] [[$(author)$]] [[quote]]


<$list filter="[<currentTiddler>prefix[Book -]]">

   
<$button> New Quote
     
<$vars author={{!!author}}>
     
<$action-sendmessage $message="tm-new-tiddler" title=<<now "YYYY.0MM.0DD.0hh0mm0ss QUOTE - ">> tags=<<newtags>> />
      </
$vars>

   
</$button>
   <$list filter="[tag<currentTiddler>!sort[title]]">
   <h2><$link><$transclude field="title" mode="block"/
></$link></h2>
   
<$transclude field="text" mode="block"/>
   
</$list>
</
$list>

Notes:
1) The newtags() macro constructs the desired tags field value, using [[...]] around each tag to handle spaces embedded in the current tiddler's title and author fields
2)  The $button gets the author field value as a variable, so that the newtags() macro can refer to $(author)$ internally

enjoy,
-e

Sapphireslinger

unread,
Nov 8, 2020, 4:47:52 AM11/8/20
to TiddlyWiki
Thank you! Works great!
(Sorry didn't thank you sooner. Sometimes I go weeks without logging in.)
Reply all
Reply to author
Forward
0 new messages