Automatic creation of Tiddler on Save?

89 views
Skip to first unread message

AJ Ferrari

unread,
Jul 25, 2020, 9:00:34 AM7/25/20
to TiddlyWiki
Sorry for the newbie question.
Is there a way to automatically create a tiddler, based on a link in an existing tiddler.

For example

If I have a tiddler which includes

[[Restaurants]]

When I save the tiddler, a new empty tiddler is created called "Restaurants"

I saw this done in Stroll, but wanted to know how I might do this in my basic Tiddler.

Perhaps there is a standalone plugin which does this?

Thanks for any help!

Ste

unread,
Jul 25, 2020, 10:53:28 AM7/25/20
to TiddlyWiki
Creating an empty tiddler if [[thing inside]] doesn't exist when you click on the link is the default behaviour in tiddlywiki.

AJ Ferrari

unread,
Jul 25, 2020, 11:24:02 AM7/25/20
to TiddlyWiki
Yes - so I want to override that default behaviour and automatically create [[thing inside]] when I hit save.
I've seen this done in "Stroll" but would like to know how it is done.

Eric Shulman

unread,
Jul 25, 2020, 11:27:17 AM7/25/20
to tiddl...@googlegroups.com
On Saturday, July 25, 2020 at 7:53:28 AM UTC-7, Ste wrote:
Creating an empty tiddler if [[thing inside]] doesn't exist when you click on the link is the default behaviour in tiddlywiki.

While this is true, it's not what the OP was asking.  Specifically,  he wrote:

"When I save the tiddler, a new empty tiddler is created.."

In other words, a new tiddler is created as soon as you save
the tiddler in which the missing link occurs, not when you
subsequently click on the link to the missing tiddler.

In Stroll, its done via $:/.giffmex/ui/EditTemplate, which redefines the save-tiddler-actions() macro like this:

\define save-tiddler-actions()
<$action-sendmessage $message="tm-add-tag" $param={{{ [<newTagNameTiddler>get[text]] }}}/>
<$action-deletetiddler $tiddler=<<newTagNameTiddler>>/>
<$action-sendmessage $message="tm-add-field" $name={{{ [<newFieldNameTiddler>get[text]] }}} $value={{{ [<newFieldValueTiddler>get[text]] }}}/
>
<$action-deletetiddler $tiddler=<<newFieldNameTiddler>>/>
<$action-deletetiddler $tiddler=<<newFieldValueTiddler>>/
>
<$action-sendmessage $message="tm-save-tiddler"/>
<$list filter="[all[current]links[]is[missing]]"><$action-createtiddler $basetitle=<<currentTiddler>>/></$list>
\end

Note the last line of the macro:
<$list filter="[all[current]links[]is[missing]]"><$action-createtiddler $basetitle=<<currentTiddler>>/></$list>

When this is invoked, it uses a $list widget to scan the tiddler's links for any that are missing,
and then triggers $action-createtiddler for each missing tiddler title.

To add this handling to your own TW document, copy these two tiddlers from https://giffmex.org/stroll/stroll.html:
$:/.giffmex/ui/EditTemplate
$:/config/ui/EditTemplate

enjoy,
-e

Mat

unread,
Jul 25, 2020, 11:34:18 AM7/25/20
to TiddlyWiki
@AJ Ferrari wrote:
When I save the tiddler, a new empty tiddler is created called "Restaurants"

I'm just curious - when is this useful, considering that the new tiddler/s are just empty?

IMO it would be more useful if one could add some data already at definition, like e.g

[[title:tags:text]] or [[title][tags][text]] or some such.

In addition to creating these one would probably also want them to be converted into a normal link, i.e so 

[[title][tags][text]] becomes just the normal [[title]]

<:-)

Mark S.

unread,
Jul 25, 2020, 4:54:41 PM7/25/20
to TiddlyWiki
It's useful in the context of Stroll -- the new tiddler will automatically show backlinks to the "parent" tiddler.

Mat

unread,
Jul 25, 2020, 5:08:59 PM7/25/20
to TiddlyWiki
Ah, thanks Mark.

<:-)

AJ Ferrari

unread,
Jul 26, 2020, 9:01:09 AM7/26/20
to TiddlyWiki
Wow - thanks.
I'm new to this software and community - its amazing, the power of this little thing! :-)

AJ Ferrari

unread,
Jul 26, 2020, 9:10:17 AM7/26/20
to TiddlyWiki
<<when is this useful, considering that the new tiddler/s are just empty?>>

If I'm creating a new tiddler - which is a group of people in my club, it might look like this

Club tiddler

[[Bob]]
[[Sally]]
[[Ted]]

When I save, I would like to have 3 new Tiddlers automatically created - so that I can later add information about them. They will also show up in my "map" = which is how I like to navigate my tiddler.

So, it basically saves me 3 steps, of manually creating those tiddlers.

Maybe, there is an easier way to do this - I'm not sure

Eric Shulman

unread,
Jul 26, 2020, 9:53:04 AM7/26/20
to TiddlyWiki
On Sunday, July 26, 2020 at 6:01:09 AM UTC-7, AJ Ferrari wrote:
Wow - thanks.
I'm new to this software and community - its amazing, the power of this little thing! :-)

All I did was dig into Dave Gifford's "Stroll" code to see how he did it.

and yes... the TiddlyWiki software has remarkable abilities, but the real power
is in the community of *helpful* users and developers surrounding that software.

-e
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)



TW Tones

unread,
Jul 26, 2020, 7:05:07 PM7/26/20
to TiddlyWiki
AJ,

Remember although the tiddler is "missing" with a new link, that title is now "live" in your wiki. It can be found.

To add to your library of approaches when you do click on a missing link and it opens a tiddler "that is missing", 
and you get the offer to edit it. 
Missing tiddler "tiddlername click  to create

In this case if you have a tiddler tagged $:/tags/ViewTemplate that conditionally displays (with a List asking if [all[current]is[missing]]) on all missing tiddlers,
Using a view template you can add information, buttons and more to assist in the creation of the new tiddler. This could allow a more considered approach to creating the tiddler such as indicating what it is eg person, their phone number etc...

Regards
Tony
Reply all
Reply to author
Forward
0 new messages