Delete Tags from within the action-sendmessage

70 views
Skip to first unread message

Ankit Mittal

unread,
Jun 18, 2020, 11:24:43 AM6/18/20
to tiddl...@googlegroups.com
Hi,

I am trying to create a tiddler using transclusion of a template tiddler with all its fields using the following inside a button. 

<$action-sendmessage $message="tm-new-tiddler" text={{template\NewInfo}} title="New Info ???" $param="template\NewInfo" tags={{{ [<currentTiddler>addprefix<pre>addsuffix<suf>] }}} />

However to keep template tiddler "template\NewInfo" easily accessible I have two tags on it "code" and "experimental" and so when I click the button I get the tag "code" and "experimental" on the new tiddler along with the tag I do want which is the title of the tiddler in which this button is. 

I need to use the $param="template\NewInfo" because I want the application type to be inherited from the template which is "text/x-htmlp" as I want to be able to edit the info from WYSWIG table that the CKEditor plugin allows.

Is there any way I can remove the two tags at the time when the new tiddler s created on click of the button?

Mark S.

unread,
Jun 18, 2020, 2:14:12 PM6/18/20
to TiddlyWiki
If you use some method to absolutely guarantee that the new title will be unique and put it in a variable (e.g title=<<my-title-macro>>), then you can add a second action using something like:

<$action-listops $tiddler=<<my-title-macro>> $field="tags" $filter="[<currentTiddler>addprefix<pre>addsuffix<suf>]" />

Or you could do it completely differently, using <$action-createtiddler> and set each of the fields yourself. You can set the type inside the widget as well (e.g. type="text/x-htmlp" > The advantage of action-createtiddler is that it takes care of name collisions for you. Even though using a template tiddler sounds like the easiest approach, I find something like action-createtiddler turns out to be the easier approach.

Michael Wiktowy

unread,
Jun 18, 2020, 3:36:57 PM6/18/20
to TiddlyWiki
To add to Mark S's reply, as I discovered recently in another thread this might be what you need:

<$action-listops $tiddler="New Info ???" $field="tags" $subfilter="-[[code]] -[[experimental]]" />

Another thing that I discovered is that sometimes actions fire in an unpredictable order but if you have this right after the tm-new-tiddler action and not in a different $list widget.

However, the bigger issue that you might experience is that if there is a name conflict, a new tiddler will be created with a different name than specified. You might use this action-listops on the template instead to remove the tags before cloning it and then put them back like

<$action-listops $tiddler="template\NewInfo" $field="tags" $subfilter="-[[code]] -[[experimental]]" />
 ... do some cloning of "template\NewInfo"...
<$action-listops $tiddler="template\NewInfo" $field="tags" $subfilter="[[code]] [[experimental]]" />

Your current $action-sendmessage doesn't handle currentTiddlers with spaces in that name though (makes multiple tags of a word each). Not sure how to fix that if that is an issue.

/Mike

Ankit Mittal

unread,
Jun 18, 2020, 4:15:52 PM6/18/20
to tiddl...@googlegroups.com
Thanks for the response guys... I managed to get it resolved by using the code below... basically I replaced $param="template\NewInfo" with specifically using type="text/x-htmlp"

<$vars pre="[[" suf="]]">
<$button style="
border:2px solid orange;
background-color:white;
color:orange;
padding: 5px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;"
>
Add New Info
<$action-sendmessage $message="tm-new-tiddler" text={{template\NewInfo}} title="New Info ???" type="text/x-htmlp" tags={{{ [<currentTiddler>addprefix<pre>addsuffix<suf>] }}} />
</$button>
</$var>

Michael, as you can see the code does take care of spaces by virtue of the variables pre and suf defined at top..

TW Tones

unread,
Jun 18, 2020, 6:39:52 PM6/18/20
to TiddlyWiki
Ankit,

I will just share a method I discovered recently when creating tiddlers from templates given its relevance.

I am working on a tool for this and found allowing fields in the template such as say object-type which may equal "template" in the template tiddler, to have a companion _object-type field which is used to replace the value of object-type during the new tiddler process. eg object-type becomes "post" instead of template.

In my Under construction blog, you can select new Post from the New Sidebar tab and see the resulting tiddler created and its fields to get an idea. 
See $:/PSaT/new-tiddlers/macros for insight to this code.

It is quite easy to then add additional actions to add tags and other contextual information into the new tiddler, which I plan to build into this new tiddler tool. It will still take time for me to finish and publish this as I am trying to make it as universal and generic as possible.

Regards
Tony

  • When finished my new tiddler solution will allow you to provide additional actions to the new tiddler process.

Ankit Mittal

unread,
Jun 18, 2020, 8:15:52 PM6/18/20
to TiddlyWiki
Thanks Tony I just checked the link and it does look very interesting and useful indeed.

I will watch the space with interest. :)

Reply all
Reply to author
Forward
0 new messages