Setting the "default" state of $:/state/sidebar of a new TiddlyWiki with an import?

I have a json file of tiddlers imported into a fresh TW initialized from the command-line, and it doesn’t appear that it imports (or it ignores) the “$:/state/sidebar” tiddler in the file.

It imports other system tiddlers like $:/SiteTitle and $:/SiteSubtitle, but this one is obviously in $:/state, so I guess it’s handled differently.

[{
        "title" : "$:/state/sidebar"
        ,"text" : "no"
        ,"type" : "text/vnd.tiddlywiki"
}]

Is there a “correct” way to default this setting on a new Wiki? I am avoiding having to have this in a full TW template loaded after initialization because I try to reserve that for less granular things that are best edited in the TW environment, and I have found handling these things in the code/data in the build process that I have is better for source control/granularity than a full TW template which might drag around extra unnecessary tiddlers from experimentation after the build.

The TWCore’s default import processing does not automatically import tiddlers with a $:/state/ prefix. You can see this if you use drag-and-drop to import your JSON file of tiddlers. While $:/state/... tiddlers will be listed in the $:/Import interface, they default to UNchecked, so they are not automatically imported.

The “correct” way to set the default $:/state/sidebar value is to create a tiddler tagged with $:/tags/StartupAction/Browser containing an $action-setfield widget, like this:

<$action-setfield $tiddler="$:/state/sidebar" $value="no"/>

After creating this tiddler, save-and-reload your TiddlyWiki. Each time your TiddlyWiki is loaded the $action-setfield widget will be triggered, setting the $:/state/sidebar value to “no”.

-e

3 Likes

Excellent, that new startup tiddler works great.