Add a new tiddler with content based on a template with a special button

Hi,

I want to facilitate creating new tiddlers containing standard content, provided by a template, with the help of a special button located next to the + button at the PageBar.

I do have a tiddler containing a new icon called “new code.svg”

The name of the new tiddler to created should be: subroutine.f90

The template for creating the tiddler should contain:

tag: fortran

!!.purplecls subroutine .f90
```fortran

** subroutine.f90**

Please advise a solution.

Many thanks in advance for your help and continuous support.

Best regards, Bapak Ireng

Try this:

First

  • Create a tiddler (e.g., “$:/custom/Buttons/new-code-tiddler”)
  • Give it a tag of “$:/tags/PageControls”
  • Set the text field to:
\whitespace trim
<$button class=<<tv-config-toolbar-class>> tooltip="Create a new Code tiddler">
<$list filter="[<tv-config-toolbar-icons>match[yes]]">{{new code.svg}}</$list>
<$list filter="[<tv-config-toolbar-text>match[yes]]"><span class="tc-btn-text">New code Tiddler</span></$list>
<$action-sendmessage $message="tm-new-tiddler"
   tags={{$:/custom/Templates/new-code-template!!tags}}
   text={{$:/custom/Templates/new-code-template!!text}}/>
</$button>
  • Add a caption field containing: “new Code tiddler”
  • Add a description field containing: “Create a new Code tiddler”
  • After pressing “done” to save the tiddler, click on the “$:/tags/PageControls” tag to display the dropdown list of tiddlers with that tag. Then, use drag-and-drop to reposition the “$:/custom/Buttons/new-code-tiddler” immediately following the “$:/core/ui/Buttons/new-tiddler” item.

Next:

  • Create another tiddler (e.g., “$:/custom/Templates/new-code-template”)
  • Give it a tag of “fortran”
  • Set the text field to:
!!.purplecls subroutine .f90
```fortran

** subroutine.f90**

That should do it. Clicking the “New Code Tiddler” button should create a “New Tiddler” with the desired tag and default text content.

Let me know how it goes…

enjoy,
-e

@EricShulman
Thank you very much for your valuable advice and support.
Your suggestion works as expected, however the new tiddler created is titled only “New tiddler” and not as “subroutine.f90” as expected. What did i wrong in this context ?

Best Regards, Bapak Ireng

Change this:

<$action-sendmessage $message="tm-new-tiddler"
   tags={{$:/custom/Templates/new-code-template!!tags}}
   text={{$:/custom/Templates/new-code-template!!text}}/>

to this:

<$action-sendmessage $message="tm-new-tiddler" title="subroutine.f90"
   tags={{$:/custom/Templates/new-code-template!!tags}}
   text={{$:/custom/Templates/new-code-template!!text}}/>

Alternatively, you could use:

<$action-sendmessage $message="tm-new-tiddler" title="subroutine.f90"
   $param="$:/custom/Templates/new-code-template"/>

Eric, thank you again very much for your very valuable help and support.
Now everything works perfectly.

Have a nice day.
best regards, Bapak ireng