View template only for one tiddler

I have a tiddler named ‘VTforPD’ tagged ‘$:/tags/ViewTemplate’ and it is listed before ’ $:/core/ui/ViewTemplate/body’. It contains:

<$list filter="[[Projectify Dashboard]]">

<<table-dynamic filter:"[tag[todo]!tag[done]due[]]" fields:"tbl-checkbox title tags">>

</$list>

I thought that this would make that dynamic table appear ONLY in the tiddler titled ‘Projectify Dashboard’. But this table appears in ALL tiddlers.

Something seems to be wrong with the syntax I am using.

How do I set things right?

1 Like

<$list filter="[<currentTiddler>match[Projectify Dashboard]]">...

-e

@EricShulman Perfect. Thanks.

In filters documentation, I had read that [[Tiddler Name]] translates to [title[Tiddler Name]]. So, I thought I was using the correct syntax.

What’s happening here is that the filter is always true : you are testing if [Projectify Dashboard] exist.

In filters documentation, I had read that [[Tiddler Name]] translates to [title[Tiddler Name]]. So, I thought I was using the correct syntax.

@deshmukh But using that as your filter returns the result “Tiddler Name,” whether or not such a tiddler exists or is the current tiddler. You can test the filter itself before putting anything inside the list:

<$list filter="[[Nonexistent Tiddler]]">
<$link/>
</$list>

In your case you want the list to be non-empty only if “Projectify Dashboard” is the current tiddler; thus @EricShulman’s response.

Best,
Chris

Edit: typo extra letter

In filters, under most circumstances, writing [fieldname[foo]] is equivalent to [field:fieldname[foo]], and only returns a result if the indicated fieldname exists in the current tiddler and contains the specified value.

However, [title[foo]] is a special case and is not equivalent to [field:title[foo]].

As explained here: https://tiddlywiki.com/#Selection%20Constructors

  • Most operators derive their output from their input. For example, many of them output a subset of their input, and thus truly live up to the name of “filters”, narrowing down the overall output of the containing run. These operators are called selection modifiers.
  • A few operators ignore their input and generate an independent output instead. These are called selection constructors: they construct an entirely new selection.

-e

1 Like

May I suggest putting a condition in the view template that is only true for one tiddler is perhaps not a very performance oriented solution. Perhaps you end up doing this a few more times and every tiddler displayed will do this test.

To support this kind of application I created a package that tests to see of a tiddler contains a field called local-viewtemplate and renders that on the current tiddler. That is it is a view template only for one tiddler. This sounds like your requirement.

In addition this package lets you edit this local-viewtemplate field as a text area in the edit template, and once created hides local-viewtemplate from the standard field editor. It allows you to have multiple one off view templates with only one condition being used in the regular view template.

I find this ideal for design and experimentation!

local-viewtemplate.json (5.0 KB)

Drop this on your wiki or tiddlywiki.com, no need to reload, edit a tiddler, add the field local-viewtemplate (should be in the dropdown list), no need to give a value, yet. scroll down in the edit view to see the locval-viewtemplate editor.

This demonstrates multi-line fields similar to the text field, please check they save and restore correctly on your saver(s) of choice and let me know if you have a problem.

With this installed you can use multiple local-viewtemplates with only one test in the standard viewtemplate.

3 Likes

@TW_Tones That was perfect. Thanks.

1 Like