How to make a template/button?

A few years ago, I used a post I found in the old Groups Email Community that gave instructions on setting up a template button. It worked great. Recently, I transferred and modified the coding for another Tiddlywiki I’m working on in an attempt to make a different button, but it doesn’t work. I can’t find the original post. I’ve searched and searched and found nothing that helps. I’m wondering if the code was only part of it. Maybe I have to add something else, somewhere else, but I have no idea what that might be, if so.

What I want to do is set up a book review template so that I add the particulars and when I save them, they all have the same format.

The image below is what I’d like to achieve, or something close to it. Please tell me if there’s a better way to do it. If I’m on the right track, please point me in the right direction because I’m lost in all these emails/posts.

Thank you for any help you can give me.

Templating is a really broad subject, especially in tiddlywiki. The best way is not to include any templating in your “content” tiddlers, but using;

  • a tiddler tagged with $:/tags/ViewTemplate and a condition that tests for a particular condition eg object-type=book-review
    • Within that template access and display the content you want to appear and its format.
  • By making use of the new cascades such as View Body template, or in some cases the Story Tiddler cascade (when you also want to influence the buttons etc… on the tiddler.

I can possibly provide a more complete answer with a little more info;

  • Is there one book review per tiddler?
  • Is the view you shared just inside a tiddler, or something else?
  • Where is the information for the various elements for the book review stored eg
    • Tiddler title is review title
    • Image field points to book cover
    • Rating is a field in the tiddler with a number of stars or I are you using the rating plugin $:/plugins/tobibeer/rate
    • The Blurb and review are in the text field

Then we also need to now how you then want to make use of this

  • Copy to paste elsewhere
  • Only display in wiki
  • Print to pdf

If we can round this down I will give a more practical answer.

Because I have the tools here is a package containing a viewTemplate body cascade, with a object-type book-review.

  • Install this in your wiki book-review-object-type-template.json (4.4 KB)

  • Edit $:/object-types/book-review/viewBodyTemplate to define how to display any tiddlers body (text field) with the object-type field set to book-review

    • by default it work as usual, and you can code additional content around the default behaviour to render the text field, or replace it completely.
    • So in the template get the image, published-date etc… and format it as desired.

Thank you. I will give it a go and see how I go.

Also, thank you for asking those questions, because that made me think about it from a different angle. Why do I want this? The answer is that I want to export about 300 book reviews from Wordpress and import them to a (under construction) Tiddlywiki website.

This means the information will come from the import document and, hopefully, populate the template and look great! :smiley:

I’m yet to try importing from an export, but will try it over the weekend in another test Tiddlywiki to see what happens.

If you see if you can Find a wordpress plugin to export your reviews as CSV then use JSON Mangler to import them as tiddlers into a plugin you will be well on your way.

  • It may be a little more fiddly with the images but it can be done.

Is there a link that gives a thorough explanation on object-type? I’m having trouble getting my head around it.

The JSON bundle that Tony posted uses a TW concept that is called “cascades”, which was introduced with TW v5.2.1

The concept is made possible with “filter run prefix” named “cascade” …

The JSON contains 6 tiddlers, where you only need to modify 1 of them → Number 2
If you import the JSON to the links below will work.

  1. $:/object-types/book-review
  2. $:/object-types/book-review/viewBodyTemplate
  3. $:/PSaT/object-type
  4. $:/PSaT/object-type/displayIcon
  5. $:/PSaT/object-type/editBodyTemplatesFilter
  6. $:/PSaT/object-type/viewBodyTemplatesFilter

#2 is the template tiddler that will be shown in the tiddler body for every tiddler that has a field named: object-type.

object-type is Tony’s creation to define a “specialized” type field, because the field-name: “type” is already used by TW core.

So if you

  • create a new tiddler eg: Aliece in Wonderland - Review
  • add a field named: object-type with the value: book-review
  • add this link to the text field: [[Alice in Wonderland]]

The tiddler body will use the template $:/object-types/book-review/viewBodyTemplate to show the content of the “Alice in Wonderland - Review” tiddler.

Since the #2 template only contains the following wikitext and some description fields. It does not do something special.


<$transclude tiddler="$:/language/MissingTiddler/Hint"/>


BUT … if you add eg:

'This tiddler contains a book review''


<$transclude tiddler="$:/language/MissingTiddler/Hint"/>


Every tiddler with the object-type:book-review field will be shown like this:

  • So you “only” have to create a template similar to your image from the earlier post.
  • Every other “normal” tiddler will not be affected by the template.

I hope that helps

See the docs about : Cascades, Cascade Filter Run Prefix


@pmario gave a good answer but ask more questions if you wish. I am in the +10 UTC time zone

Thank you for the explanation. I will return to this project after lunch and see if I can work it all out.

I’m in +10 too. :slight_smile:

Kind regards,

Hi Karen,
Having a closer look at your initial review screenshot I did remember a concept for floating images that I did create in 2017. … I did find the macros, modernised them and here it is.

  • First import Tony’s JSON with the new viewTemplate concept
  • Then import my JSON with the floating image concept
    • It contains 1 macro tiddler
    • 1 little CSS that allows image to float left, right and center
    • 1 little docs tiddler
    • and … a “non empty” version of $:/object-types/book-review/viewBodyTemplate which should look similar to your screenshot.
  • There is 1 Alice in Wonderland - Review tiddler as an example, how the tiddler content could look like.

The only problem I see is the “Blurb” section, if it should have more than 1 paragraph. … May be it should not. There is a solution for this one too :wink:

have fun!

book-review-concept.json (4.4 KB)

1 Like

@TW_Tones and @pmario
Please accept my sincere thanks for your time and effort in helping me with this mission. I must admit that it took me a long, long time to work out how to install the two JSONs, but I managed it in the end and I’m pleased that I perservered. It’s exciting to see everything start to come together. Here is a look at a sample book review.

Looks great! Again, thank you so much. I am so happy with it. :smiley:

Naturally, I still have questions and I hope you won’t get tired of answering them. For now, I have two questions:

  1. As mentioned before, I have about 300 book reviews that I would like to import. I believe I have to export them from the source first, change the headings to match what I have in Tiddlywiki and then import to my Tiddlywiki. I think I’ll be OK with this bit. But I don’t understand how the import will know to look for the book review template?

  2. Once all the book reviews are in my Tiddlywiki, I’ll want to add more each time I finish reading a book. So, how do I create a new book review? I notice “fields” have been created in Alice, so should I create a button with these fields so that I have a blank template?

As always, I appreciate your time and efforts.

kind regards,

1 Like

I discovered the answer to question 2. I made a New Review Button using the fields in the template and it works like a charm. :slight_smile: And, it didn’t take two days, so I’m even happier.

Yes, that’s probably the the trickiest part. I don’t know how the export format from WordPress looks like. But TW has s CSV (comma seperated values) import plugin and a plugin for importing from Excel.

I do not use them myself, so someone else would need to jump in here. … But I did a short Google search and found this: Export any WordPress data to XML/CSV – WordPress plugin | … so there are probably plenty of WP plugins, that you can use.

The simpliest import for TW is a TID file. eg: alice.tid which would need to look like this.

title: Alice
tags: tag1 tag2 [[tag with spaces]]
book-rating: ... 
book-blurb: ... 

The text comes here with 1 empty line between the fields above and the main text. 

If it is possible to create something like this, it will be very straight forward to import it into TW. Every other format is more complex.


Thanks for the quick reply. I know I can export a XML/CSV. I think I’ll attempt a small export and import into another test wiki to see how it works out.

Once you have the data, you could use Tiddler Commander for batch processing to rename fields or other changes, that you may need.

It would be very useful to be able to import data from WordPress blogs. WordPress has a standard, built-in XML export format that doesn’t need a plugin:

It’s not something I can work on right now, but I’d be happy to help anyone who wanted to pick it up.


If you can export a few reviews and share the file, I would be happy to look at an import process for you.

  • I have done a fair bit of this and interested in building a generic WordPress to TiddlyWiki process.

I attempted to export from Wordpress and import to Tiddlywiki, and it didn’t really work.

Firstly, I exported from Tiddlywiki to see what it looks like and got the following:

Nothing unusual there. I expected to see this.

Then, I exported to XML from Wordpress, and imported to Tiddlywiki. While the data imported, it all appeared in one tiddler. I don’t know if that is normal or not, but it would take me a long time to fix and to me was not ideal. The file looked like this:

So I found an exporter to CSV for Wordpress and it was closer to what I need as the data was in columns. However, it brought across a lot of Wordpress coding, which is a pity:

I’m not sure how to move forward from here. The time it will take to tidy up the spreadsheet, could take me days, unless there’s a way to strip the Wordpress coding. More research is required. Does anyone have any suggestions?

I can help more later, but I am quite busy this weekend. Some tips to get you started,

  • How many posts do you have to convert? This can make a big difference to the approach.
    • You may find even with a 100 or so you could copy and paste content, making use of Browser addons, even select, drag and drop, to copy as text etc… it would take a few hours ONLY
  • CSV is normally the best way
  • Some wordpress plugins are better than others at exporting.
    • You can see which fields/columns to not export.
  • WordPress sits on top of a database and someone with the skills, even some online guides can tell you how to export via database query.
  • If something is reoccurring like <!-- wp:paragraph --> its easy to remove with search and replace, but this is a comment and will not display anyway.
  • Some tools for CSV such as CSV Editors, exist that can help you “clean up your data” before you use a wiki with the “JSON Mangler” installed to import, select and convert them into tiddlers.
    • Most Spreadsheets can help you edit CSV as well.
  • If you can share a sample of your csv file, I and others can help more.

I am happy to help you here, but if you want you can engage me professionally to do the whole JOB.

Could you export 3 reviews into XML format and attach them here, so we can see, how they look like?