|
|
Thread Tools | Search this Thread |
06-29-2021, 03:28 AM | #1 |
Groupie
Posts: 156
Karma: 12649
Join Date: Feb 2020
Device: iPad
|
Have the series number in the generated cover only when it is not zero
The subtitle for generated book covers contains the Series name plus the Series number. This is acchive with the following template code:
Code:
{series:'test($, strcat("<i>", $, "</i> - ", raw_field("formatted_series_index")), "")'} I looked for a "greater than" test in the Template Program Modesection of the doco, but couldn't figure it out... |
06-29-2021, 04:50 AM | #2 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
Advert | |
|
06-29-2021, 08:59 AM | #3 |
Groupie
Posts: 156
Karma: 12649
Join Date: Feb 2020
Device: iPad
|
Thanks for chiming in @chaley!
I tried the "if" expression path, because I do not really need the numeric comparison, a string comparison against "0" should be enough. However I get an error. The full code for my sub title expression looks like this: Code:
{series:'test($, strcat("<i>", $, "</i>", program: if raw_field("formatted_series_index") == "0" then "" else raw_field("formatted_series_index"),"<br>"), "")'} {#version:'test($, strcat("<b>", $, "</b>"),"")'} |
06-29-2021, 09:31 AM | #4 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
There are several errors.
Code:
{series:' test($, strcat( "<i>", $, "</i>", if raw_field("formatted_series_index") ==# 0 then "" else raw_field("formatted_series_index") fi, "<br>"), "")'} {#version:'test($, strcat("<b>", $, "</b>"),"")'} Code:
program: if $series then if $$#formatted_series_index ==# 0 then dex = "" else dex = $$#formatted_series_index fi; s = strcat("<i>", $series, "</i>", dex, "<br>") else s = '' fi; if $#version then v = strcat("<b>", $#version, "</b>") else v = '' fi; strcat(s, v) |
06-29-2021, 10:08 AM | #5 |
Groupie
Posts: 156
Karma: 12649
Join Date: Feb 2020
Device: iPad
|
Thanks a lot @chaley!
That's great tip to convert the complete tetemplatee to TPM. I didn't know that's possible. It's soo much easier! Basically I went with your TPM solution, I just made a few adjustments to your version to accommodate better my setup. For completeness I list that here: Code:
program: if $series then if $$formatted_series_index == "0" then dex = "" else dex = strcat(" - ",$$formatted_series_index) fi; s = strcat("<i>", $series, "</i>", dex, "<br>") else s = '' fi; if $#version then v = strcat("<b>", $#version, "</b>") else v = '' fi; strcat(s, v) |
Advert | |
|
06-29-2021, 11:16 AM | #6 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
What is the lookup name "formatted_series_index"? There is no standard column with that name and it isn't a custom column because it is missing the leading '#'?
|
06-29-2021, 05:56 PM | #7 |
Groupie
Posts: 156
Karma: 12649
Join Date: Feb 2020
Device: iPad
|
I disagree (not that I'm a calibre expert): The default template for the subtitle was:
Code:
{series:'test($, strcat("<i>", $, "</i> - ", raw_field("formatted_series_index")), "")'} |
06-30-2021, 04:22 AM | #8 |
Grand Sorcerer
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
For those who come across this thread later, the above is only partially true. The template is being evaluated in the context of generating a cover, which is the only place in calibre where the field "formatted_series_index" is valid.
|
06-30-2021, 04:29 AM | #9 |
Groupie
Posts: 156
Karma: 12649
Join Date: Feb 2020
Device: iPad
|
|
Tags |
series name, series number, template language |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tags for author sort, series and series number? | griffitts | Calibre | 4 | 02-06-2020 11:37 AM |
Margin cutting off portion of number generated from <li> | stephenTOS | Kindle Formats | 5 | 07-07-2017 02:28 PM |
Can series-number metadata be a number range? | Suffolk Punch | Calibre | 4 | 04-29-2017 01:53 PM |
Generated Cover Error | dvd8n | Calibre | 3 | 07-16-2013 01:01 PM |
How do I change the generated cover? | DarkAbsynthe | Calibre | 2 | 10-29-2010 10:22 PM |