Managing Tiddler Fields from a Dynamic Template

Is it possible to make tiddlers from a template, whereby all tiddlers created using that template remain linked to it after creation, so that if new fields are added to the template, all the tiddlers created with it are automatically given those new fields (and conceivably default values for each field)?

Essentially the goal is to create a database type structure, with each tiddler having a set of fields to hold the relevant information about an entry. I anticipate that the set of fields I initially can think of will evolve and grow over time, and it could get quite inconvenient to go back and add new fields manually to every entry.

I can see one way to create tiddlers with a predefined set of field via the tm-new-tiddler widget message, but if I understand right this looks like a one-way deal (i.e. previously-created tiddlers will not receive new fields added to the template definition later down the line).

Does anyone know if there’s a better template approach that will allow for such a “dynamic template” functionality?

i’m not sure if it is possible to have them dynamically update (others can weigh in on that), but you can manually update them all at once with the commander plugin - filter the text for the template (or a shared tag, field value etc) and then just add the field and value to them all at once.

It’s not possible to have a “connection” between existing tiddlers and a template, that created them out of the box.

Have a closer look at the ActionCreateTiddlerWidget Examples. They will show you what you need.

@wixl I have done something similar but held back from making it automatic. In a view template that is displayed on the tiddler template, I list all fields used by the instances of that template (tiddlers created from the template) and test if they exist in the template. I can manualy, with a button, add extra field to the new tiddler template and or propergate them to existing instances.

  • some instances of a tiddler may have one off unique fields I do not want to add to all instances. That is why its manual but has tools to make it easy.
  • when I do apply a new field it isvavailable from that point forward.
  • I use action set field to add and set fields
  • I used action list ops to add values to list fields

However once a tiddler is created from the template I also have view template and edit “templates” based on a tiddlers object-type eg contact. Changing this to include a new field makes it available but only creates it on a given tiddler if edited. No batch add needed.

To cause changes to be propergate to instances need a trigger, Typicaly a button containing actions including with a list inside the button. A batch operation.

  • for truely automatic you can use an appropriate startup action to trigger this rather than a button, just make sure it can run every time and only make changes if it must.

When you say a link to the template you can have a logical connection. For example I have an $:/objects/contact which is the new contact tiddler template and every contact tiddler has object-type=contact so its easy to see, link to or list between instances and templates eg [{!!object-type}addprefix[$:/objects/]]

  • I always use fields and values rather than tags for any purpose other than system tags and ad hoc tagging.
1 Like

I second the suggestion to check out the Commander plugin by @Mohammad.

Also very helpful is the dynamic tables feature (part of Mohammad’s Shiraz plugin). It will allow you to work efficiently with a spreadsheet-like overview of relevant fields, seeing easily where some new dimension of data might need to be back-filled for older tiddlers.

Thanks for the ideas and information. commander looks like a super useful plugin which will definitely be a powerful tool in all kinds of tiddlywiki maintenance tasks.

It sounds like you have a thought-out system and workflow @TW_Tones - it feels like I may end up building something similar, so I expect I’ll refer back to this as I go.

Thanks @Springer, you leap-frogged me! As I was just typing: …another useful workflow I stumbled upon today that makes “post-creation bulk updates” somewhat easy to work with is via dynamic tables in the shiraz plugin. One can create a table filtered to all tiddlers that need the new field added, create a table column for such a field (even though it doesn’t yet exist in any of the tiddlers listed), and then just go down the table rows adding the required values to the new field column, which creates the entry in the tiddlers as you go.

A shout-out to @Mohammad for two great plugins seems required!

1 Like

i kind of worked around a similar issue by using “clone tiddler” on an existing sibling tiddler, so the new sibling has the correct fields. then erasing the main text field. maybe a modified/tweaked clone tiddler button could create a clone without some fields such as the main text field?

also a happy user of shiraz dynamic tables!