I want to prepend {{||ContactInformation}} to all ‘[tag[Contact]]’ tiddlers. I read about this and tried the following code:
<$button>
<$action-setfield $tiddler="[tag[Contact]]" text="{{||ContactInformation}}"/>
<$action-navigate $to="$:/ControlPanel"/>
Go to Control Panel "Appearance" tab
</$button>
But that does not work. So I added the <$list> widget like so:
<$button>
<$list filter="[tag]Contact]]">
<$action-setfield $tiddler=<currentTiddler> text="{{||ContactInformation}}"/>
</$list>
<$action-navigate $to="$:/ControlPanel"/>
Go to Control Panel "Appearance" tab
</$button>
But that did not work, either.
Moreover, even if it did, it would replace the contents of the text field, I want to prepend the field.
oldtext=... fetches the current contents of the target tiddler
newtext=... defines the stuff to add
Note the blank line at the end of the definition of “newtext”… this is important, since you want to make sure that a blank line is added between the newtext and the oldtext in order to preserve any “block mode” formatting of the oldtext (e.g., if the old text started with a bullet item, etc.)
If you want a solution without having to hard code {{||ContactInformation}} to every contact tiddler, you can use viewtemplate. Create a tiddler with the following content:
Pak’s response is the correct “TiddlyWiki Way” to do this.
Using a ViewTemplate automatically shows the ContactInformation in every tiddler tagged with “Contact”… and, when you create new “Contact” tiddlers, they will also automatically show their ContactInformation as well, without having to remember to add the syntax to those new tiddlers.
Also, my solution, while it addresses your specific question, is somewhat problematic… each time you press the button, it will add the {{||ContactInformation}} syntax to every “Contact” tiddler, even those tiddlers for which the syntax has already been added.
@Pak Thanks. This works perfectly except that the text size of the text produced by view template appears to be smaller than that of the text produced directly or by transclusion as template.
So, a heading two line coming from the view template appears to be smaller in size than a heading two line in the body.
What could be the reason behind this? How to fix this?