How to use viewtemplate's

I am a bit confused after ploughing through the viewtemplate documentation.

As I understand it, a viewtemplate is used to format the display of the current tiddler. I also believe it is possible to have different display formats (hence differing viewtemplates) for different tiddlers but how is this done? I can not see how to select a viewtemplate based on a tiddler’s content.

Sorry if this is a newby question, but I am oping to get some pointers so I can progress in my understanding.

bobj

@Bob_Jansen I use tags, checking for specific tags in a ViewTemplate.

<$list filter=“[is[current]tag[person]]”>
Show content for a person. 
</$list>

You can extend this to check for specific fields or even a specific value of a field.

1 Like

@clsturgen, so how does this work? Is there a single viewtemplate tiddler with many $list filter’s to cater for each type of tiddler, person, organisation, exhibition, etc? Or is there a separate viewtemplate for each type?

From my reading, I suspect the latter but thought I’d ask to be sure but assume that the former is a way to implekent it as well, albeit possibly more complex coding.

bobj

2 Likes

The answer is you decide, both are possible. I tend to use one view template for a given solution, or plugin, or perhaps for each drastically different view.

For me in learning tiddlywiki was thinking about view templates was to call them “conditional view templates” to always wrap the content of a view template (tagged tiddler) in a condition, because they are always included in the view template with the $:/tags/ViewTemplate tag, and this condition determines when the result is visible.

It becomes a view template simply by addition of the $:/tags/ViewTemplate

If in separate tiddlers with their own tag, their display order can be change by the order of items so tagged. If they are all in the same tiddler, the order is either as listed serially in the code, or if you implement you own sort order within that tiddler.

  • Use separate tiddlers if you want them to be displayed in different places in the view template
  • Use the same tiddler if you want them to always display together in a particular order, where ever it appears in the view template.
2 Likes