How to create and implement templates for different tags?

I have a tiddlywiki for book notes. The wiki has two type of tiddlers. One for direct quotes and another for my own thoughts. I would like to have two different templates that are called depending on whether the new tiddler is a quote or a personal thought. This needs to include fields.

My quote tiddler has a number of fields:

book-title
book-reference (ie page number)
quote-author

Currently my personal thoughts tiddlers have the same fields, but this is likely to change in the furture.

Quote tiddlers are tagged with “Quote” and personal thought tiddlers are tagged with “Thought”.

What I would like to be able to do is set two buttons in my home tiddler that would represent these two tiddler types. If I click one button, it should create a new tiddler according to the template that the button represents, ie quote or thought.

How to accomplish this is a big mystery and any help would be appreciated.

I am working through Soren Bjornstad most excellent Grok Tiddlywiki, but am producing quite a lot of reading notes and would like to nail this down asap.

Hi SVS,

My recommendation as someone who just “graduated” from Grok Tiddlywiki is to work around this problem until you (soon) reach the chapters covering this exact issue. This will help you apply the theory to something that is highly relevant to you and thereby improve uptake. In the meantime, simply clone an existing quote tiddler when wanting to create a new one and replace the field content. It’s only marginally slower and will help you stave off frustration to save a valuable practical learning opportunity for a bit later.

Best

1 Like

The ActionCreateTiddler tiddler has example code that can be easily adapted to do what you. The last or 2nd to last example in particular.

https://tiddlywiki.com/#ActionCreateTiddlerWidget

Hi, @svs —

I do this a lot in my TiddlyWikis, and while there may be a newer, more streamlined way to go about it, I’ll share my method using my own “new quote” button as an example.

I’ve thought about updating this to use the <$action-createtiddler> widget, but that will only create the new tiddler. The method below will create it and open it in edit view so you’re ready to start filling it in with your own input.

If you’re going to have some starter text to remind you to format the body of all your quotations tiddlers the same way, create a “skeleton” tiddler to use as a template. This may not apply in your case, as it looks like you’re going to be using fields to keep track of the same information I put in the body of the tiddler. But if you’re curious, mine looks like this:

The tags and naming conventions are just ways I keep track of my system tiddlers. The dependents field is there to remind me where I use this skeleton (in a button).

… and here’s what the tiddler for that button looks like:

Again, the tags and naming conventions are just ways I keep track of tiddlers, especially ones I reuse in multiple wikis.

If you want to have your custom fields available to fill out when you first create the new tiddler, just edit this bit in $:/ui/secret-hq/buttons/new quote:

<$action-sendmessage $message="tm-new-tiddler" text={{$:/skeletons/secret-hq/quote}} title="New quote." tags="$:/tags/Quote" />

… to include your fields with empty values, e.g.:

<$action-sendmessage $message="tm-new-tiddler" text={{$:/skeletons/secret-hq/quote}} title="New quote." tags="$:/tags/Quote" book-title="" book-reference="" quote-author="" />

Of course, you may also want to ditch that bit about text={{$:/skeletons/secret-hq/quote}} if you aren’t going to use a skeleton tiddler, and you’ll probably want to edit or delete tags to suit your use case.

You can also ditch class="new-tiddler-button" from the initial <$button> element. That’s a custom style I use to keep all my buttons of this type the same width because I keep them in a sidebar tab to give me easy access for creating different types of tiddlers on the fly — “+ new quote,” “+ new stylesheet,” “+ new skeleton,” etc.

Here are .TIDs of those two tiddlers from my collection if you’d like to play around with 'em:

$__skeletons_secret-hq_quote.tid (383 Bytes)
$__ui_secret-hq_buttons_new quote.tid (580 Bytes)

1 Like