Link to widget to create tiddler, If tiddler doesn't exist

103 views
Skip to first unread message

James Anderson

unread,
Jul 12, 2021, 2:18:04 PM7/12/21
to TiddlyWiki
Hello,

I would like to create a link to create a tiddler using a template if that tiddler does not exist.

e.g. in tiddlywiki.com have a new tiddler:

```
\define AList() [[Full Edition]] [[Empty Edition]] [[Blog Edition]] [[Non Existing Edition]]

<$list filter=<<AList>>>

<$link to={{!!title}}>{{!!title}}</$link>

</$list>
```

キャプチャ1.PNG

instead of linking to Non Existing Editing directly i would like to link to a widget that will create it from a template. e.g. https://tiddlywiki.com/#ActionCreateTiddlerWidget the last example here. but if it does exist link to it normally.

Any tips on how to achieve this?

Thanks,
James

Charlie Veniot

unread,
Jul 12, 2021, 8:10:32 PM7/12/21
to TiddlyWiki
G'day James,

I don't have a solution for that, but maybe this can be useful in the meantime?

Eric Shulman

unread,
Jul 12, 2021, 10:03:39 PM7/12/21
to TiddlyWiki
On Monday, July 12, 2021 at 11:18:04 AM UTC-7 james.w....@gmail.com wrote:
I would like to create a link to create a tiddler using a template if that tiddler does not exist.

Try this: 
\define AList() [[Full Edition]] [[Empty Edition]] [[Blog Edition]] [[Non Existing Edition]]
<$list filter=<<AList>>>
   <$list filter="[<currentTiddler>is[tiddler]]"> <$link /> </$list>
   <$list filter="[<currentTiddler>is[missing]]">
      <$button class="tc-btn-invisible tc-tiddlylink"> <<currentTiddler>>
         <$action-createtiddler $basetitle=<<currentTiddler>> $template="NewEditionTemplate" aa="new field aa" bb="new field bb" />
         <$action-navigate to=<<currentTiddler>> />
      </$button>
   </$list>
</$list>

Notes:
* The first inner $list widget uses the "shorthand" <$link /> syntax to link to the currentTiddler
* The second inner $list widget displays a $button that looks like a link that
  A) creates the missing tiddler using NewEditionTemplate (if defined), as well as a few other fields defined "inline"
  B) navigates to the newly created tiddler

enjoy,
-e

James Anderson

unread,
Jul 18, 2021, 4:21:39 PM7/18/21
to TiddlyWiki
Thanks Eric! that did the trick.
Reply all
Reply to author
Forward
0 new messages