New Tiddler based on a Template

I have partially solved this challenge, but it does not quite work as I intended.

I am trying to create a new button that creates a new tiddler based on a “template”. What is failing is the new tiddler does not contain the fields specified in my template.

So I have two tiddlers.

NewPropertyButton tagged as $:/tags/PageControls
with this code in the body:

<$button class=<<tv-config-toolbar-class>> tooltip="Add new Property">
   <$list filter="[<tv-config-toolbar-icons>match[yes]]">
    <span class="chunk">{{$:/images/fa5/solid/home}}</span>
   </$list>
   <$list filter="[<tv-config-toolbar-text>match[yes]]">
      <span class="tc-btn-text"><$text text="New Property"/></span>
   </$list>
   <$action-sendmessage $message="tm-new-tiddler" tags="property" title="Enter Property Name" text={{NewPropertyTemplate}}/>
</$button>

and

NewPropertyTemplate
which is empty apart from defining three fields:
built, demolished, opened

Is there someting missing from my code or do I need to explicitly state the fields to be included?

Thanks.

You need to wrap you code in your post as code. See the </> icon.

Try replacing the above with the following:

<$action-sendmessage $message="tm-new-tiddler" $param="NewPropertyTemplate" tags="property" title="Enter Property Name" />

Also see the examples given in the documentation: https://tiddlywiki.com/#WidgetMessage%3A%20tm-new-tiddler

1 Like

I cannot get the syntax right for this or find a help page that illustrates where the </> needs to be placed. Can you demonstrate with my code, please.

Thanks

While editing posts in Discourse select the code and click the </> icon.

  • Or wrap in triple backticks like in tiddly wiki
  • For in line code use single back ticks

if it is about adding fields to your newly created tiddler you can also add them directly in the sendmessage.

<$button class="tc-btn-invisible tc-mytw-button-new-edit" tooltip="edit new task">
   {{edit}}
   <$action-sendmessage 
      $message="tm-new-tiddler" 
      title={{$:/state/newTaskTitle}}
      tags="!task"
      project={{$:/my/tag/focus!!project}}
      category={{$:/my/tag/focus}} 
   />

When making new tiddler buttons look at the actioncreateTiddler widget it is has more options, with it you can use a named tiddler as the source of the text field text={{template}} and add fields fields .