Tiddler Templates?

225 views
Skip to first unread message

Darth Mole

unread,
May 23, 2021, 3:19:29 AM5/23/21
to TiddlyWiki
I apologize in advance, I feel like I'm being dense in not being able to find the answer to my question. I think I may be overthinking it/using the wrong terminology in my searches. 

What I'm curious about is if there is a way to create multiple Tiddler Templates so that it will prepopulate a list of questions/content when selected. I'm trying to use TiddlyRoam as an open source alternative to Obsidian, which is a self-hosted alternative to Roam Research.

I want to use TiddlyRoam as world building software (I already use the base TiddlyWiki) and want to try and have prebuilt "templates" for Tiddler topics such as "Character" or "Town" or "Country" or "Group (IE: guild, venture, etc.)" where the base questions/information are already there for me just to answer/fill-out.

I thought about Content Types being the answer, but again I think I'm just confusing myself and I don't even know if I can do it.

Thank you in advance and again my apologies!

Soren Bjornstad

unread,
May 23, 2021, 9:33:49 AM5/23/21
to TiddlyWiki
You may be getting confused because "template" typically means something different in TiddlyWiki. I don't know if there's a better name for this, though. :-/

If I'm understanding what you want correctly, the simplest method is with a button that sends a tm-new-tiddler message. For instance, here's a simplified version of one I have for adding a new source to my Zettelkasten:

\define new-source()
  <$action-sendmessage
    $message="tm-new-tiddler"
    title="New Source"
    tags="Source"
    caption=""
    medium=""
    url=""
    readstatus="unread"
    year=<<now "YYYY">>
  />
\end

<$button tooltip="New Source" actions=<<new-source>>>
  New Source
</$button>

Click on the button and a new tiddler is created with the field values you specify in the new-source macro.


There are other ways to accomplish this too which may have their own advantages...this is just one I often use.

Mat

unread,
May 23, 2021, 10:26:22 AM5/23/21
to TiddlyWiki
Hi iamdar... I'd approach it like so:

Create a tiddler that contains the things you want. Tag it with $:/tags/ViewTemplate

Surround the content with a "conditional listwidget" i.e something that recognized some unique characteristic for e.g "character" or "town" etc. The simplest might be to tag all such tiddlers with that tag. I.e surroudn the template code with:

<$list filter="""[all[current]tag[Character]]""">
(the template code)
</$list>

Then to have it apply to a tiddler, you just tag that tiddler Character. In viewmode, you'll then see the template which can have e.g SelectWidgets and stuff.

Note that in the code, you use <<currentTiddler>> to refer to the tiddler that the template is used in. (That [all[current]...] could actually be written [all<currentTiddler>....] but it is a special case for the all[] operator)

BTW, if this really IS what you're after, then the term is "conditional templates" (...even if I'm not sure it is used in the docs, but it ought to be)

<:-)

Darth Mole

unread,
May 24, 2021, 11:24:10 AM5/24/21
to TiddlyWiki
First of all, thank you both very, very, very much! Shortly after I posted my original message I found some references to what I was trying to find but this community is great. You both responded with answers despite my lack of finding them on my own. Again thank you!

As for the solution:

Mat, yours was the closest as far as concept, and I was able to make it work as you described (thank you!), however it isn't exactly what I was looking for. If the data (the template code) was automatically added to the tiddler after saving, and then allowed me to fill out the information/answer the questions/etc afterwards then it would have been perfect. In this case it only creates a reference to static data, which can also be helpful and that I may use.

Instead of a filter is there a way to do an "insert" or something similar where it happens once on the initial save and then inserts the template/data so that the info can be filled out when it is next edited?

Soren, I was also able to get your suggestion working (thank you!) and was able to create a solution for my needs. Though I would prefer an automatic insert based on the tag I add (just based on my current workflow) having a tab with a list of buttons that call the different templates that I have prepared will also work. Thank you very much!

Again thank you both for your replies and help!
Reply all
Reply to author
Forward
0 new messages