Can I choose a template when clicking a wiki link to a non-existent (missing) tiddler?

So I type a wiki link in to a field or just the body of a tiddler. It does not yet exist. When I click the link, I get the standard interface telling me this is a missing tiddler and to click edit to create it.

But what if I need to create it using a specific template?

I’m toying with some genealogy research, so this would mostly be typing in a relative’s name in a wiki link, but then I need that new tiddler to use a ‘person’ template.

I guess I’m kinda asking how to apply a template to an already existing tiddler?

I tried using this in a tiddler (inside a table) but it makes a teeny-tiny button in view mode:

<$button><$action-sendmessage $message="tm-new-tiddler" $param="New Person" title="{{!!father}}" /></$button>

That does, in fact, use the template, but it never pulls in the contents of that field for the new tiddler title, just inserts the field name in braces. And of course TW doesn’t want braces in a tiddler title. I feel like I’m going to need to assign the field name to a variable first?

  1. teeny-tiny button
    Your button doesn’t have any label text. Use something like:
    <$button> New Person <$action-sendmessage ... /></$button>

  2. title parameter
    The delimiters surrounding a widget parameter value depends on the type of parameter value:
     • quotes surround literal text
     • curly-braces surround tiddler/field references
     • angle-brackets surround variable references
    Thus, to use the value of the father field, remove the double-quotes around the parameter value, like this:
    <$action-sendmessage ... title={{!!father}}/>

-e

1 Like

Another approach to handling missing tiddlers is to make use of what happens when you open a missing tiddler, just follow the link and be given new from template options.

Following a missing tiddler link opens the default tiddler view template $:/core/ui/ViewTemplate/body/default but because there is no tiddler to transclude the inner transclusion of $:/language/MissingTiddler/Hint occurs.

<$transclude>

<$transclude tiddler="$:/language/MissingTiddler/Hint"/>

</$transclude>

You could modify $:/language/MissingTiddler/Hint to present the “new from template buttons”, using the current tiddler name.

Alternatively you could add a new $:/core/ui/ViewTemplate/body/default using the cascade mechanism.

1 Like

I developed a “viewTemplate body” cascade alternative, to handle missing tiddlers, so thought I would share it here;

Basically once installed it comes before the standard $:/core/ui/ViewTemplate/body/default and uses the one provided $:/PSaT/handle-missing/ViewTemplate-body in which you could add new tiddler buttons.

Basically when you follow a link to a missing tiddler you get the opportunity to create the tiddler there.

handle-missing.json (1.1 KB)

That’ll do it! Still happens if the field is empty, but this is just for me so it’s all good

Yep, that was it - thanks!

OK, I imported the three files from the json file, but I remain unsure what to add to the ViewTemplate-body file, and where to add it…

Open the above tiddler and place the button code to create the tiddlers from your templates there.

  • The tiddler you create will use <<currentTiddler>> The missing tiddler title.
  • You will see your buttons when you follow any missing link, where you can click to edit or click your button to create.

This example button just creates the tiddler but has no templating;

<$button message=tm-new-tiddler param=<<currentTiddler>> >Create <<currentTiddler>> </$button>

I will find an example button if you can’t build it yourself.

  • In your button at the top of this thread it needs Eric fix OR
  • I suggest instead you use the actionCreateWidget and set the basetitle=<<currentTiddler>>

[Edited] See https://tiddlywiki.com/#WidgetMessage%3A%20tm-new-tiddler and the last example, if you want additional parameters using tm-new-tiddler you must use and action widget, you cant add additional parameters inside the button widgets parameters because it has its own set of parameters only message=tm-new-tiddler and param=tiddlername work inside the <$button here>

2 Likes

OK, my ViewTemplate-body is working well like this:

<$transclude>

;Create missing tiddler using the New Person template:
<$button>New Person<$action-sendmessage $message="tm-new-tiddler" $param="New Person" title=<<currentTiddler>> /></$button>

;Create new tiddler using the default missing "template":
<$transclude tiddler="$:/language/MissingTiddler/Hint"/>

</$transclude>

Click the button, you get this:

Need to have the option to select more than one solution on Discourse! :frowning:

For what it’s worth, I’ve been keeping a running list of the tweaks I’ve made to make Markdown feel more native. Here’s what I have so far: Configuring TiddlyWiki for Markdown.tid (1.7 KB). I’ve been thinking it would be nice to integrate all these little quality of life tweaks to create a full Markdown Edition as opposed to the Markdown Demo that is available in the codebase.