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.
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.
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.
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!
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.
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
@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.
Naturally, I still have questions and I hope you won’t get tired of answering them. For now, I have two questions:
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?
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?
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. 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.
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.
Done.
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.
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.
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.