Passing tiddler fields as parameters of a widget

94 views
Skip to first unread message

Littleagle Thoronaug

unread,
Nov 19, 2019, 10:24:40 AM11/19/19
to TiddlyWiki
Hi there!

I'm using TW5 in a single file, version 5.1.21 and I want to pass the content of a field as a parameter of a widget. I tried transcluding, using variables, using parameters of a macro but none of them seem to work. This is what I tried:

<$fieldmangler tiddler="Draft of 'Añadir $type$' by {{$:/status/UserName!!text}}" >
or
<$fieldmangler tiddler="Draft of 'Añadir $type$' by <<uservar>>" >
or
<$fieldmangler tiddler="Draft of 'Añadir $type$' by $(uservar)$" >
even
<$fieldmangler tiddler="Draft of 'Añadir $type$' by $user$" >

where "user" is a parameter of a macro inside of which is the $fieldmangler widget.

I need this to remove a tag in that Draft of using $action-sendmessage widget.

Thanks in advance.


Mark S.

unread,
Nov 19, 2019, 1:22:46 PM11/19/19
to TiddlyWiki
This worked for me:

\define removetag(type user)

<$fieldmangler tiddler="Draft of 'Añadir $type$' by $user$" >
<$button message="tm-remove-tag" param="TEST">Remove TEST tag</$button>
</$fieldmangler>
\end

<<removetag text Jose>>

Where the original tiddler before being opened for edit was "Añadir text" Just to be clear, the tiddler needs to be opened for editing in order for this to work (for it to have the name "Draft of 'Añadir text' by Jose"

Good luck!

Littleagle Thoronaug

unread,
Nov 20, 2019, 3:00:09 AM11/20/19
to TiddlyWiki
Maybe I didn't explained properly. Sorry for that.
In the example you send me, I need the call to the macro receives the content of a field as parameter. Like this:

<<removetag text {{myTiddler!!caption}}>>

I'll try to explain more:
If you set a username in the config, every draft opened appends 'by username' in the title. This username is stored in the tiddler $:/status/UserName. I have a button in my wiki that triggers a tm-new-tiddler action based on a template. This opens a tiddler for editing with the contents of the template, including the tag of the template ($:/tags/template) and I want to remove it before saving the new tiddler.
But I can't send the content of $:/status/UserName as a parameter of the function in order to concatenate it after 'Draft of ... by'.

I know it could be easily done by typing the username in the macro (as is a single file and there is only one user) or simply deleting de username from de config, but I plan to make this wiki multi-user in the future.

Thank you!

Eric Shulman

unread,
Nov 20, 2019, 3:29:52 AM11/20/19
to TiddlyWiki
On Wednesday, November 20, 2019 at 12:00:09 AM UTC-8, Littleagle Thoronaug wrote:
Maybe I didn't explained properly. Sorry for that.
In the example you send me, I need the call to the macro receives the content of a field as parameter. Like this:

<<removetag text {{myTiddler!!caption}}>>

To invoke a macro that uses the content of a field as a parameter value, you can use the <$macrocall> *widget* syntax rather than the <<macroname>> macro syntax.

For example, if you have a macro named "myMacro" that has two parameters, param1 and param2, and you want to pass a field value as param2, you would write:

<<$macrocall name="myMacro" param1="literal text" param2={{!!fieldname}} />

hope this helps,
-e
Eric Shulman
TiddlyTools: "Small Tools for Big Ideas!" (tm) http://tiddlytools.github.io/ (TWClassic)
InsideTiddlyWiki: The Missing Manuals http://insidetiddlywiki.tiddlyspot.com/ (TW5)

Littleagle Thoronaug

unread,
Nov 20, 2019, 3:50:55 AM11/20/19
to tiddl...@googlegroups.com

To invoke a macro that uses the content of a field as a parameter value, you can use the <$macrocall> *widget* syntax rather than the <<macroname>> macro syntax.

For example, if you have a macro named "myMacro" that has two parameters, param1 and param2, and you want to pass a field value as param2, you would write:

<<$macrocall name="myMacro" param1="literal text" param2={{!!fieldname}} />

hope this helps,

I've just had a flash five minutes ago and I remembered macrocall. I've been trying it and it works!!
So if anyone has the same problem, here is the answer:

<$macrocall $name="myMacro" param1="literal text" param2={{!!fieldname}} />


Thank you so much Mark and Eric!

Edit: Should I mark this as solved? How? Thanks
Reply all
Reply to author
Forward
0 new messages