Indexes & Links

Tuesday, February 20, 2018

TiddlyWiki - Lists and Fields

I've written a few posts about using TiddlyWiki 5 (TW5) to manage campaign notes.  Recently, I've been playing around with lists and tags in hopes of better organizing some categories of information, specifically, NPCs.

A quick summary of the TW5 features I'll talk about today for those who are unfamiliar:
  • TW5 is a single-file wiki you can keep on your computer.
  • It stores chunks of information, called tiddlers, you can link together.
  • A markup language makes it simple to format (most) content.
  • You can tag tiddlers with labels that are also tiddlers.

One of the nice things about using tags is you can quickly create lists of tiddlers that are tagged with a specific label as I outlined here. But, this also leads to the issue I run into when organizing NPCs. If your wiki has tiddlers for 100 NPCs, and each uses the character's name as a tiddler name and tagged with NPC, the list created using the procedure above is just a list of names. That's... not very useful. Who can remember all those names?

What you really want is a list that includes a brief description of each character. It turns out that's not all that hard. Here's how I did it.

The first step is creating the short descriptions we want to display in our tag lists. TW5 makes it easy to add bits of data, called fields, to individual tiddlers. I added a field called sdesc (short description)  to each NPC tiddler and filled it out with a brief description of the character. In most cases, this was a cut/paste job from the body of the character's tiddler.

Next, I had to display this description in a useful format in the NPC tiddler. Remember, tags are also tiddlers, and these tiddlers are a great place to summarize categoric information or make lists of tagged tiddlers.

The old method:

     <<list-links filter:"[all[current]tagging[]] +[sort[title]]" >>

This boils down to "list all the tiddlers tagged by the current tiddler and show their titles as links in a sorted list."

For our new list, we want to show the same list of links, plus the contents of the sdesc field from each NPC tiddler. After digging through TW5 mailing lists and websites I hit upon this:

     <ul><$list filter="[all[current]tagging[]] +[sort[title]]">
     <li><$link>{{!!title}}</$link> - {{!!sdesc}}</li>
     </$list>
     </ul>

Looking at this a piece at a time:

  • <ul></ul> - HTML code for a unordered list.
  • <li></li> - HTML code for a single list item.
  • <$list filter="[all[current]tagging[]] +[sort[title]]"> - Create a sorted list of all tiddlers tagged by this one.
  • <$link>{{!!title}}</$link> - Show the title of an individual list entry.
  • {{!!sdesc}} - Short the short description field.
  • </$link> - the closing tag for the list.

The end result is a nicely formatted bullet list with NPC names and descriptions. Just what the GM ordered. As an added bonus, any TW5 markup in the sdesc field is interpreted when it's displayed. In the wiki for my Colony game. For example, the short description for Mosc Inja indicates he's the owner of the White Tulip and includes link markup to the White Tulip tiddler. That makes it really easy to figure out who's who and find related information on the fly, which is the real power of using TiddlyWiki.


No comments:

Post a Comment

Note: all comments are moderated to block spammers. Please be polite.