![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Template editor and Date columns
I noticed an error on a metadata plugboad when looking at the details on the device. It was caused by using more than one library and not updating the plugboards across them all. So, I copied the updated plugboard to the new library. When I did this, there was an error shown in the template editor:
Code:
EXCEPTION: Interpreter: Unknown field '#kobo_last_read' - line number 4 Reducing this to the minimum, the template is: Code:
program: kobo_last_read_str = test($#kobo_last_read,strcat('<p><b>Last Read:</b> ', $#kobo_last_read, '</p>'),''); When I connected the device, it worked. The comment was updated with the correct string depending on if there was a value in #kobo_last_read. After playing with this a bit, it appears that there are problems with date type fields. I have several in the test library and they all gave the error. They usually give the above error. But, there is also a difference between opening the template editor from the metadata plugboard screen and for a custom column. I always get it the error when opened from the metadata plugboard screen, but, not always from the column editor. But, I haven't got a consistent behaviour for that. Changing the template to use the "field" function didn't change it. But, "raw_field" or using $$#kobo_last_read did. In this case: Code:
program: kobo_last_read_str = test(raw_field("#kobo_last_read"),strcat('<p><b>Last Read:</b> ', raw_field("#kobo_last_read"), '</p>'),''); Code:
<p><b>Last Read:</b> ('#kobo_last_read',)</p> Code:
program: kobo_last_read_str = test(field("timestamp"),strcat('<p><b>Last Read:</b> ', field("timestamp"), '</p>'),''); This is with calibre 5.32 on Windows 10. I am normally running from source. But, I did check the above against the installed version. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
To be sure I understand, the problem exists when you open the template editor from the plugboards dialog? If so then it happens because that dialog doesn't have a book from which to get metadata. It compensates for this by creating a fake book from field metadata, setting each column value to the column name. This fails for non-text fields like date.
I submitted a fix that sets column type-correct values for the made-up book. It is in source now. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
That's pretty much it. And would explain what I saw. And it has fixed my test case.
I did get something strange when opening the template editor by pressing F2 on the column in the list. Or maybe from the column editor. But, I can't work out the combination and can't reproduce it now. It was probably user error. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Template: sum of multiple integers from other columns | Quuzuu | Library Management | 4 | 01-17-2021 04:35 PM |
Showing template-computed columns as [rating] stars isn't possible? | kaoruAngel | Library Management | 2 | 11-06-2017 08:49 AM |
Need help in Custom Columns, template syntax, and rounding numbers | dennocoil | Calibre | 0 | 07-10-2017 03:24 PM |
Request: template-making assistance for column built from other columns | iienderii | Library Management | 9 | 04-04-2016 10:27 PM |
Template editor | Jellby | Calibre | 4 | 08-23-2014 03:10 AM |