Conditionally showing subtitles in the view template

Preface, this modifies system tiddlers, I’d recommend making a backup of your TiddlyWiki (like with any changes made) and if you want- you can take these snippets and make them into a plugin, you have my blessing (not that it’s needed lol) so the changes can be done and undone at your leisure!

. . .

So, one of the little things I decided I would like to see on all my tiddlers is, if there is creator and modifier, I’d like to see both of them, and same goes for the created and modified fields, BUT, if those fields didn’t exist, why take up the space?

So, here’s what I did.

  1. open up every tiddler prefixed with $:/core/ui/ViewTemplate/subtitle/ which should give you two tiddlers, one for modified, and one for modifer. (I found it odd we don’t have tiddlers for creator and created fields, so I made those tiddlers by simply cloning the previous two.)

  2. replace the default text (and I used the modified tiddler for the example) with: <$reveal type="nomatch" state="!!modified" text="" retain="yes"> __modified__: <$link to={{!!modified}}/> </$reveal>

2.1. Optional Step, you can change the date format of these tiddlers and other elements by modifying the tiddler $:/language/Tiddler/DateFormat. I personally use [UTC]YYYY-0MM-0DD 0hh:0mm since I personally and professionally use systems that use UTC for tracking stuff.

2.2. You may need to use list-before and list-after fields on the system tiddlers to get them in the order you prefer. I have mine as creator > created > modifier > modified but you do you!

2.3. If you would like to only see the modifier subtitle if it is different from the creator field, you can achieve that by just doing <$reveal type="nomatch" state="!!creator" text={{!!modifier}} animate="yes" retain="yes"><$reveal type="nomatch" state="!!modifier" text="" animate="yes" retain="yes">__modifier__: <$link to={{!!modifier}}/></$reveal></$reveal>

So, the end result?

Subtitles that show when they exist, labelled with what each bit of data is, in whatever order or format you’d like.

5 Likes