Text in a tiddler tagged with "$:/tags/ViewTemplate" appearing twice?

82 views
Skip to first unread message

Graham

unread,
Jan 27, 2020, 11:12:18 AM1/27/20
to TiddlyWiki
Hello I have a bit of a problem that I hope someone will be able to help me with.

What I want to do:

I have a template (titled "TemplateTiddler") tagged with "$:/tags/ViewTemplate" that adds a template to selected tiddlers.

I want to display some text only within TemplateTiddler that reminds me what my particular template is for/how it works etc.

What I have tried:

I added the following list widget:

<$list filter="[TemplateTiddler]">
Here is some text that I want to display in TemplateTiddler.
</$list>

The problem is that the text gets displayed twice. Presumably it is displaying the original text in the filter and transcluding it via the "$:/tags/ViewTemplate" tag.

Is there a method for getting it to display only once?

Thanks in advance for your help.

Mat

unread,
Jan 28, 2020, 3:41:19 AM1/28/20
to TiddlyWiki
Hi Graham.

I think I understand what you're after, and it is something I do myself. What you actually want is a *second* viewtemplate.

So, irrespective of that first one, create a new tiddler with the following fields. (You can change the name to be a system tiddler (prefix $:/) once you're happy with it):

name: ViewTemplate/description
tags: $:/tags/ViewTemplate
text:
<$list filter="[all[current]has[description]]">
<div style="border:1px solid crimson; color:gray; padding:1em;">{{!!description}}</div>
</$list>
description: If a tid has a `description` field, then its content is shown before the tiddler body.

This will show a description for *any* tiddler that has a description field. 
Yes, looking at this very tiddler, you'll see its message twice but that is only for this particular tiddler.
You can globally rearrange the position of the appearing description by clicking the viewtemplate tag (in any tiddler that has one) and drag'n drop reorder the listing.

<:-)

Graham

unread,
Jan 28, 2020, 4:11:42 PM1/28/20
to TiddlyWiki
Thank you Mat - exactly the solution I needed!

TonyM

unread,
Jan 28, 2020, 5:13:54 PM1/28/20
to TiddlyWiki
Here is another way

In your tiddler "My Tiddler" tagged $:/tags/ViewTemplate
try this

<$list filter="[all[current]!title[My Tiddler]]" variable=nul>
This is my tiddler on view template only
</$list>

<$list filter="[all[current]title[My Tiddler]]" variable=nul>
This is "My Tiddler" itself
</$list>

But a sorter method if your templates are only ever system tiddlers, and you want the view template to show only on regular tiddlers and not on itself
$:/myViewTemplate
<$list filter="[all[current]!is[system]]" variable=nul>
This is $:/myViewTemplate on view template only for non system tiddlers
</$list>
<$list filter="[all[current]is[system]!title[$:/myViewTemplate]]" variable=nul>
This is "$:/myViewTemplate"  is system but not myself
</$list><$list filter="[all[current]is[system]]" variable=nul>
All system tiddler including myself $:/myViewTemplate
</$list>
The trick is the hardcoded tiddler title and using variable=nul to not change the currentTiddler for the content you display
Use whichever set of list statements that suit your need

One caveat if you tag this same tiddler to appear in the sidebar and on other parts of the page the currentTiddler will not be returned and this test will will fail. 

Regards
Tony
Reply all
Reply to author
Forward
0 new messages