Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Server

Notices

Reply
 
Thread Tools Search this Thread
Old 01-02-2022, 03:10 PM   #1
HunterRose
Junior Member
HunterRose began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2022
Device: iPad
Book list template question

I am trying to update my custom book list template to show if a book has the Completed tag or not.

{tags} works fine, but I'm not interested in seeing the whole string, especially as it make take multiple lines.

I have tried

Code:
{str_in_list(field('tags'),',','Completed','Incomplete')}
and

Code:
{contains(field('tags'),'Completed','Completed','Incomplete')}
and nothing is appearing in the generated output. I have also inserted 'program:' inside the first bracket with the same non-results.

What nuance am I missing here?

Last edited by BetterRed; 01-02-2022 at 08:07 PM.
HunterRose is offline   Reply With Quote
Old 01-02-2022, 03:11 PM   #2
HunterRose
Junior Member
HunterRose began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2022
Device: iPad
P.S. Hey, the word 'Incomplete' does not have spaces in it in either instance that I typed, but the forum software apparently knows better.
HunterRose is offline   Reply With Quote
Advert
Old 01-02-2022, 08:09 PM   #3
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,777
Karma: 27405072
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by HunterRose View Post
P.S. Hey, the word 'Incomplete' does not have spaces in it in either instance that I typed, but the forum software apparently knows better.
Solution: put code-like text in code blocks

The '#' icon in the advanced mode toolbar will do it for you.

BR
BetterRed is offline   Reply With Quote
Old 01-02-2022, 08:36 PM   #4
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303822
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by HunterRose View Post
I am trying to update my custom book list template to show if a book has the Completed tag or not.

{tags} works fine, but I'm not interested in seeing the whole string, especially as it make take multiple lines.

I have tried

Code:
{str_in_list(field('tags'),',','Completed','Incomplete')}
That looks like you are trying to search for the tag "Completed" and return something. There are two problems. Firstly, the structure of the call is incorrect. The other is that you are missing a parameter. The "str_in_list" requires at least five parameters. The list to check, the divider to use, the item to search for, the result to return when it is found, and the result to return when it is not found.

What you probably want is:

Code:
{:str_in_list(field('tags'), ',' ,'Completed', 'Complete', 'Incomplete')}
But, as you mention adding "program:", I would use:

Code:
program:
str_in_list(field('tags'), ',' ,'Completed', 'Complete', 'Incomplete')
Quote:
and

Code:
{contains(field('tags'),'Completed','Completed','Incomplete')}
and nothing is appearing in the generated output. I have also inserted 'program:' inside the first bracket with the same non-results.
There is a similar issue with that one. I would use something like:

Code:
program:
contains(field('tags'), 'Completed', 'Completed', 'Incomplete')
But, I would use the first "str_in_list" as to me that is more obvious as to it's intention.
davidfor is offline   Reply With Quote
Old 01-02-2022, 09:37 PM   #5
HunterRose
Junior Member
HunterRose began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2022
Device: iPad
davidfor, thank you for your assistance, I am trying out your suggestions.

(It appears that my original post was edited to improve formatting and one of the 'Completed's was dropped along the way.)
HunterRose is offline   Reply With Quote
Advert
Old 01-02-2022, 10:39 PM   #6
HunterRose
Junior Member
HunterRose began at the beginning.
 
Posts: 4
Karma: 10
Join Date: Jan 2022
Device: iPad
(Partially) Solved!

OK, my major difficulty was trying to place the formula in the book list template itself - checking one of the 'related' threads reveals that the book list template does not evaluate expressions.

The solution is to create a custom column that evaluates to the desired value and putting the name of the column in the book list template:

#status column contains template
Code:
{tags:in_list($,', ',Completed,Complete,Incomplete)}
book list template contains
Code:
{#status}
This appears to be generating correct results, although I see the occasional single quote mark returned instead of Complete or Incomplete. No idea what's up with that, gonna stop beating my head against the table for tonight.
HunterRose is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom list template Laval Related Tools 6 10-11-2022 09:13 AM
Conditional statements or scripting in "Book list template" ? Boilerplate4U Calibre 4 08-30-2021 11:53 PM
Template: Matching an entire list ownedbycats Library Management 20 05-09-2021 11:08 PM
Book List question Grenpa Kobo Reader 4 12-19-2014 08:21 PM
Create a template to only list one author. PMGeuze Calibre 2 12-04-2013 02:53 PM


All times are GMT -4. The time now is 07:30 PM.


MobileRead.com is a privately owned, operated and funded community.