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

1 Like

@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"/>
1 Like

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

Hi,

i try to setup the above mechanism again in Tiddlywiki 5.3.8 and unfortunately i cannot get it to work at all.
There is NO Image of the special button, only a blank space - after - the new tiddler button.
Pressing the “new button” does not open a new tiddler- as expected.

The prior solution worked in an older version of Tiddlywiki, but not in 5.3.8.
Unfortunately I lost the the Tiddlywiki instance.
For editing I use Tiddlydesktop 0.0.20 now.

What kind of mistake happened to me ?

the content of $:/custom/Buttons/new-code-tiddler is as follow:

\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" 
$param="$:/custom/Templates/new-code-template"/>
</$button>

the content of $:/custom/Templates/new-code-template looks like:
!!.purplecls subroutine .f90


** subroutine.f90**

Well,I appreciate very much your continuous help and support.

Reagrds, Ireng

Everything inside you button is effectively invisible, just add some text and that will be displayed :nerd_face:

Welcome @hitam4450

@TW_Tones
thanks for your advice. However where i have to add some text ?

When I copy/paste your code into a new tiddler at https://TiddlyWiki.com, it doesn’t show anything.

This is because the default settings are:

  • tv-config-toolbar-class="tc-btn-invisible"
  • tv-config-toolbar-icons="yes"
  • tv-config-toolbar-text="no"

Thus, the $button is displayed with no border or background (so it looks like normal content) and, since new-code.svg doesn’t exist, there is no image to display.

However, if I change the image transclusion to something like {{$:/core/images/spiral}} (i.e., an existing TWCore shadow tiddler), then a button image IS displayed, and clicking that image DOES perform the tm-new-tiddler message action, resulting in a new tiddler being opened for editing.

So… it seems that all you need to do is to add a new-code.svg image tiddler.

-e

@EricShulman

Thank you very much fo your very kind and helpful contribution.
This was last, missing piece of the puzzle to make it complete.

best regards, Ireng

1 Like