Custom ViewTemplate For Tiddlers With Empty Bodies?

I see that there is a way to override the default ViewTemplate for the body of a tiddler, but this appears to be only for a missing tiddler, showing the message that the tiddler doesn’t exist yet and can be created by clicking the new-tiddler button.

Is there a different system tiddler I could override to do something like this but instead to show a custom template, say a list-links macro of all the tiddlers the currentTiddler is tagging, if the text field of the tiddler is empty?

Or would this require me to modify the actual default ViewTemplate of the entire tiddler?

You may have a closer look to this thread: Create and Use of Virtual Tiddlers

2 Likes

Funnily enough I just started reading it, though I think I have to read further into it, so far it sounds like modifying missing tiddlers, called virtual tiddlers, but maybe I’m mistaken.

I will circle back to this once I finish reading through :blush:

You’re looking for the ViewTemplateBody cascade. Conveniently enough, @pmario (:wink:) has a nice introductory tutorial.

In this case, you’d want something like [!has[text]then[MyListTemplate]] in the config tiddler, which should be positioned above $:/config/ViewTemplateBodyFilters/default in the $:/tags/ViewTemplateBodyFilter tag-pill. Then put the actual template you want to use in MyListTemplate — perhaps something like this:

<<list-links "[tag<currentTiddler>]">>

Alternately, if you’d like to see a list of all tiddlers tagged with a given tiddler regardless of whether that tiddler has text content or not, skip the ViewTemplateBody cascade and tag MyListTemplate with $:/tags/ViewTemplate instead. Then use the tag-pill to position it where you want it relative to the other ViewTemplate segments.

3 Likes

Yep! that was the exact thing I was looking for, thank you @etardiff :grin:

For some reason my brain was set on it being a modification of the default template lol

The title of the thread (and much of the discussion) is good, but I’m still not sure why it begins with a wiki post focused on tiddlers with a $:/virtual prefix. This is a significantly different sense of virtual nodes from the kind of node that just works, semantically, with a tag name or fieldname.

Somewhere in that thread is my demo of a virtual-node-approach. (Maybe I’ll contribute to the wiki, but I am not sure I understand what @Mohammad had in mind with that first post, so I’m reluctant to edit it.)

(Of course, once one has virtual nodes, one can also see how those viewtemplates apply — either via $:/tags/ViewTemplate or via cascade condition — when a tiddler does exist, but lacks a text field…)

Right. I did completely forget about that one :slight_smile:

2 Likes

I recall there is a way to hide the buttons displayed using CSS, perhaps this could target the current tiddlers from style tags in the body template, for example to hide the edit button?

See my reply: Create and Use of Virtual Tiddlers - #17 by Mohammad

2 Likes

This post was flagged by the community and is temporarily hidden.