How do I set tags in action-createtiddler?

192 views
Skip to first unread message

Mat

unread,
Apr 27, 2021, 1:52:28 PM4/27/21
to TiddlyWiki
I wish to create a new tiddler using action-createtiddler (because it uses the "basetitle" to prevent overwrites). I define the title and tags values via a temp tiddler in some EditTextWidgets, as you see below.

But I want the new tiddler tags to be both this arbitrary temp!!tgs value AND and the title of the current tiddler (i.e {{!!title}}). The temp!!tgs value is not surrounded by brackets and it may contain spaces. The current tiddlers title is a normal tiddler title.

I'd appreciate any help on how I can set the tags here?

\define newtid()
<$button> click
<$action-createtiddler $basetitle={{temp!!ttl}}  tags=????????/>
</$button>
\end

<$edit-text tiddler=temp field=ttl/>
<$edit-text tiddler=temp field=tgs/>
<<newtid>>

<:-)

Michael Wiktowy

unread,
Apr 27, 2021, 2:44:02 PM4/27/21
to TiddlyWiki
I've only been able to do this sort of thing by taking advantage of the fact that buttons can fire two actions in sequential order: <$button action<<second_action>>> <<first_action>></$button>.

So you can use <$action-createtidder $savetitle="$:/temp/new_button_tiddler"> in <<first_action>> to save the *actual* title and not the base title and then use it in in the second_action like:

<$fieldmangler tiddler={{$:/temp/new_button_tiddler}}>
<$action-sendmessage $message="tm-add-tag" $param=<<currentTiddler>>/>
</$fieldmangler>


and stick a {{||ButtonHere}} in a new tiddler to see it in action.

You might be able to adapt it to your needs.

/Mike

Mohammad Rahmani

unread,
Apr 27, 2021, 2:55:38 PM4/27/21
to tiddl...@googlegroups.com
Hi Mat

This is one quick solution

\define mytags() [[$(tag1)$]] $(tag2)$
\define newtid()
<$button> click
<$vars tag1=<<currentTiddler>> tag2={{temp!!tgs}}>
<$action-createtiddler $basetitle={{temp!!ttl}}  tags=<<mytags>> />
</$vars>

</$button>
\end

<$edit-text tiddler=temp field=ttl/>

<$edit-text tiddler=temp field=tgs/>
<<newtid>>


* the mytags macro makes a substitution so with the help of $vars it returns the wikified values
* in the second inputbox you can enter xx yy to add two tags at the same time
* if your tag has space in name use [[my tag with space]] xx yy This will add all three tags plus currentTiddler
* If you always want to enter one tag including those with space then correct the mytags macro as below
\define mytags() [[$(tag1)$]] [[$(tag2)$]]



Best wishes
Mohammad


--
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 view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/30d188db-9d29-43c4-8bfa-1b184c46411fn%40googlegroups.com.

Mark S.

unread,
Apr 27, 2021, 3:45:29 PM4/27/21
to TiddlyWiki
Just for variety

\define newtid()
<$vars lb="[[" rb="]]" spc=" ">
<$button> click
<$action-createtiddler $basetitle={{temp!!ttl}}  tags={{{[{temp!!tgs}addsuffix<rb>addsuffix<spc>addsuffix<lb>addsuffix<currentTiddler>addprefix<lb>addsuffix<rb>]}}}     />
</$button>
</$vars>
\end

<$edit-text tiddler=temp field=tgs/>


Mat

unread,
Apr 27, 2021, 3:54:17 PM4/27/21
to TiddlyWiki
Guys, thank you! I'll look closer at it tomorrow but I'm pretty sure your solutions will solve it! Thank you.

<:-)

TW Tones

unread,
Apr 27, 2021, 6:35:23 PM4/27/21
to TiddlyWiki
Mat,

Mohammad used a macro to do the concatenation of values and Mark used the triple curly braces to use a filter to do the concatenation. These are both good methods
  • In some cases the macro approach will need the result be be wikifiy[ed] before use
  • In other cases the triple curly braces approach may need to be wrapped in <$text text={{{ filter }}} /> to have the result as plain text.

I am confident we can develop a clearer approach to concatenation as well as document it further. My personal preference at the moment is the {{{ filter }}} method as long as you feel comfortable with filters,  this is because you can do the "concatenation" at the last possible movement, although it could have performance consequences.

Regards
Tones

Reply all
Reply to author
Forward
0 new messages