TW5: Conditional ViewTemplate basics

340 views
Skip to first unread message

Dave

unread,
Oct 20, 2018, 2:23:41 AM10/20/18
to TiddlyWiki
What are some good links for learning the basics of changing the view template conditionally, both adding and subtracting elements based on tag or field?

I've found some complicated topics, but not any basic basic stuff.

I thought it would be on the tiddlywiki.com site but couldn't find it there


Thanks,
- Dave

TonyM

unread,
Oct 20, 2018, 7:04:31 AM10/20/18
to TiddlyWiki
Dave,

The basic stuff

Typically the best way to "change the view Template" is to use the $:/tags/ViewTemplate Tag on a tiddler that contains what you would like to appear, keeping in mind you can wrap it in a conditional list or reveal. You can then use the $:/tags/ViewTemplate tag pill to drag and drop the order they appear on the view template. Start simply, the enhance, you will pick it up quite quickly.

I think this is the place to look for your current requirement.

Rebuild or modify the whole view template

However some may wonder how to totally change what appears in the viewTemplate, create additional templates or ones for inside other tiddlers in a panel like TWOutlier or https://tiddlywiki.com/#Example%20Table%20of%20Contents%3A%20Tabbed%20Internal This is much more complex.



Regards
Tony

Mat

unread,
Oct 20, 2018, 9:23:58 AM10/20/18
to TiddlyWiki
"conditional viewtemplate" - scary term but really easy to do.

Basically just make a tiddler like so:

title: whatever
tag
: $:/tags/ViewTemplate
text
:
<$list filter="[all[current]xxxxyour-additional-conditionsxxxx]">
  whatever should be seen
in the tiddlers that fulfill this condition
</$list>

for example the filter might be

[all[current]tag[foo]]


<:-)

Dave

unread,
Oct 20, 2018, 10:58:04 AM10/20/18
to TiddlyWiki
Thank you both :)

So before I go tinkering (I'm sitting with morning coffee), my initial summary is this: you copy the entire existing view template, put it in a tiddler tagged with the viewTemplate tag, then you modify it with the conditions as you said, and ...

** that new viewTemplate replaces the old one which sits inactive there as a shadow tiddler until yours is deleted or untagged? **

Is that correct?

Mat

unread,
Oct 20, 2018, 11:20:06 AM10/20/18
to TiddlyWiki

you copy the entire existing view template, put it in a tiddler tagged with the viewTemplate tag,


Hm, just make a completely new tiddler and tag it $:/tags/ViewTemplate. That makes it a viewtemplate.

Type "adfs afasdfasdf" into it and save and you'll see that it appears in *all* tiddlers. That is an "UNconditional viewtemplate" if you want a formal term that I just made up.

Now instead put some "condition" around that text, such as by using a listwidget as proposed previously and it will only show when that condition is met - just like the listwidget always does. That's what I meant with that "conditional viewtemplate" sounds like something more scary than it is. It really is the tag that makes it a viewtemplate and then you put whatever you want inside it.

<:-)

Mat

unread,
Oct 20, 2018, 11:21:46 AM10/20/18
to TiddlyWiki

** that new viewTemplate replaces the old one which sits inactive there as a shadow tiddler until yours is deleted or untagged? **



just like always; if you make a tiddler with the same title as a shadow tid then this new tiddler replaces the shadow tid. The title is the identifier of a tiddler.

<:-)

Mark S.

unread,
Oct 20, 2018, 11:29:59 AM10/20/18
to TiddlyWiki
I don't see anything in the existing posts about replacing the viewTemplate.

When you tag a tiddler with $:/tags/ViewTemplate the contents of that tiddler get added to every tiddler.

You can click on the $:/tags/ViewTemplate tag and rearrange the items so that your new tiddler appears at the top or bottom of the list. Usually you don't want to replace the entire body of the default tiddler because that would be a lot of work. Usually you just want to add something new like {{!!myfield}} to reveal the contents of a particular field. Often you want to wrap the contents of your tiddler as Mat explained so that it is only used under certain conditions (often based on a tag name, for instance).

I'm surprised that there isn't anything at TiddlyWiki.com explaining this use -- it's a very common paradigm.

-- Mark

Dave

unread,
Oct 20, 2018, 1:10:19 PM10/20/18
to TiddlyWiki
ok, thanks -

I see how to add an item and rearrange the tag pills below the $:/tags/ViewTemplate in order to add an item. (You're right - nice and simple!)


How do you conditionally *delete* and item, e.g. if I want every tiddler tagged "notSoBusy" to not show the tags like normal,

do I go into

$:/core/ui/ViewTemplate/tags


and alter that tiddler by adding the filter conditions there, or is there a better way to do that?"

Mark S.

unread,
Oct 20, 2018, 1:43:15 PM10/20/18
to TiddlyWiki
Yes, that should do it. The easy way would be to make the filter something like:

[all[current]!tag[notSoBusy]tags[]sort[title]]

but that will suppress all tags.

You could instead make it:

[all[current]tags[]] -[[notSoBusy]] +[sort[title]]

which will just hide the notSoBusy tag. Of course, it will hide it from you as well as anyone else.  I think I would tend to just use a field and hide it (a simple configuration tiddler will allow you to hide/unhide it)

-- Mark

Dave

unread,
Oct 20, 2018, 2:59:48 PM10/20/18
to TiddlyWiki
Merci Beaucoup!
Reply all
Reply to author
Forward
0 new messages