Adding or removing tags from newly created tiddlers

I’m trying to make a ViewTemplate that would put a button on tiddlers with a certain tag (tpl-maker). Pressing the button should clone the tiddler, add/remove tags and open it in edit mode. So far I’ve got the cloning and opening in edit mode part working:

<$list filter="[all[current]tag[tpl-maker]]" variable="null">
	<$button>
		<$action-createtiddler $template={{!!title}} $savetitle="tmp-tpl-maker"/>
		<$action-sendmessage $message="tm-edit-tiddler" $param={{tmp-tpl-maker}}/>
		<$action-deletetiddler $tiddler="tmp-tpl-maker"/>
		New Tiddler
	</$button>
</$list>

But I cannot figure out how to add or remove tags. I’ve tried with fieldmangler, but it either modifies the tiddler being cloned, or does seemingly nothing at all:

<$list filter="[all[current]tag[tpl-maker]]" variable="null">
	<$button>
		<$action-createtiddler $template={{!!title}} $savetitle="tmp-tpl-maker"/>
		<$fieldmangler tiddler={{tmp-tpl-maker}}>
			<$action-sendmessage $message="tm-remove-tag" $param="tpl-maker"/>
			<$action-sendmessage $message="tm-add-tag" $param="new-tag"/>
		</$fieldmangler>
		<$action-sendmessage $message="tm-edit-tiddler" $param={{tmp-tpl-maker}}/>
		<$action-deletetiddler $tiddler="tmp-tpl-maker"/>
		New Tiddler
	</$button>
</$list>

How can I add or remove tags on a tiddler just created with a button (without additional interaction)?

hmmm. maybe you could manipulate the tags field of the original tiddler with the toggle operator, then pass the tags field into the cloned tiddler. something like:

<$action-createtiddler $template={{!!title}} $savetitle="tmp-tpl-maker" tags={{{[enlist{!!tags}] +[toggle[tpl-maker]toggle[new-tag]]}}} />

I’m not sure whether the $template will override the tags field, though. Good luck!

1 Like