Button catching currentTiddler title as tag

In my new TW playground, I use button definitions like this one :

\define SocieteButton()
<$button tooltip='Ajouter une nouvelle société' aria-label='Nouvelle société' >
<$action-sendmessage $message="tm-new-tiddler" $param="$:/.my/template/Société" title="Nouveau Tiddler" tags="Société" />
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/new-button}} Société
</$list>
</$button>
\end
<<SocieteButton>>

This is fine, this button creates new tiddler using a template to get specific fields and tags in the new tiddler. I also transclude this button in any tiddler where I need this function.

But now transcluding this button in a tiddler named MyTiddler I would like to set the tag of my new tiddler to the title of MyTiddler as in the NewHere button.
I looked at $:/core/ui/Buttons/new-here but I’m a bit lost in /procedures and set parameters to reverse engineer it…

Any help would be greatly appreciated.

Try the version below. Note tags=<<storyTiddler>> would normally work to pass the name of the enclosing tiddler to the new-tiddler action as a tag, but if your title has spaces in it, you would end up with a tag for each letter in the title. The version below uses the titlelist format to ensure using the button inside Hello There would make just a single tag with that string.


\define SocieteButton()
<$button tooltip='Ajouter une nouvelle société' aria-label='Nouvelle société' >
<$action-sendmessage $message="tm-new-tiddler" $param="$:/.my/template/Société" title="Nouveau Tiddler" tags={{{ [<storyTiddler>format:titlelist[]] }}} />
<$list filter="[<tv-config-toolbar-icons>prefix[yes]]">
{{$:/core/images/new-button}} <<storyTiddler>>
</$list>
</$button>
\end
<<SocieteButton>>

Thank you for your solution that works fine! I would never have found this myself.

1 Like