How to build a respawn-function that can execute action-widgets for a LandingPagePlugin?

In Tiddlymap there is the Respawn-Plugin, that brings back the default Tiddlers if the storyriver is empty.

For building a LandingPagePlugin that makes use of Layouts, it would be good to have a more flexible version of this which allows to define actionswidgets stored in a config-tiddler to be excecuted in that case. How would I build that.


title: $:/plugins/felixhayashi/respawn/respawn.js
type: application/javascript
module-type: startup



  /*jslint node: true, browser: true */
  /*global $tw: false */
  "use strict";
  var configTRef = "$:/plugins/felixhayashi/respawn/config";
  var changeListener = function(changedTiddlers) {
    if(!changedTiddlers["$:/StoryList"]) return;
    var tObj = $"$:/StoryList");
    if(tObj && !tObj.fields["list"].length) {
      var confTObj = $;
      var config = confTObj ? confTObj.fields : {};
      window.setTimeout(function() {
          type: "tm-home"
      }, parseInt(config.delay) || 500);
  }; = "respawn";
  exports.platforms = ["browser"];
  exports.after = ["story"];
  exports.synchronous = true;
  exports.startup = function() {
    $"change", changeListener);


In my opinion it should be simple to modify $:/core/ui/PageTemplate/story so the filter that reads:


instead reads:

[list[$:/StoryList]] :else[list{!!$:/DefaultTiddlers}]

Unfortunately it doesn’t seem to work (why?) and there doesn’t seem to be any documentation about :else

I guess also [list[$:/StoryList]else{!!$:/DefaultTiddlers}enlist-input[]] should work but it doesn’t either, and the previous expression feels more appropriate to me.

Hi @twMat thank you! But will this execute an actionwidget?

No, that’s why I only quoted part of our OP.

If the action is to be executed when the user clicks to switch between LandingPage and TW then I guess the obvious thing is to tie the action to that button. If the action is to be executed upon page load then it would have to be among the startup actions. I know this is possible but not exactly how. Maybe it’s as simple as giving it a StartupActions tag (docs)

There may be prior art calling this respawn but perhaps is would be more helpful using tiddlywiki standard terminology such as “saving and reopening the story, for each layout” may result in better search results.

For example save and restore a story for each layout?

Some thoughts that may help

I have ideas about how to intercept the Change layout mechanism or making full use of the emptyMessage on the story $:/config/EmptyStoryMessage

  • As soon as you identify or make a trigger you can include any actions you want.
  • I think it premature to look at a Javascript solution
  • FYI $:/snippets/LayoutSwitcher is using the Link Catcher widget with the “to” parameter, when it could be using the “actions” parameter.
    • It may be smart to make your own independent layout switcher, at least during development.
  • If you have a LandingPagePlugin that makes use of Layouts then when you exit that, you are simply changing layouts. That is you should have a trigger available to initiate change layout actions.
  • Typically a Wiki should load a particular way unless additional info is passed on the URL eg a named tiddler or that triggers a startup action.
    • If designed well the startup actions will simply be the same as in a modified layout switcher.

I’m using the TW built in $:/config/EmptyStoryMessage tiddler to show the GettingStarted tiddler if the story river is empty.

IMO there should be no need for a new function. It should also work with layouts if they respect that config tiddler. … Which they should

1 Like