View Single Post
Old 07-30-2011, 04:23 AM   #6
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,463
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by HDvision View Post
u mean i can shorten the template?
i mean it does already what i want it to do
so what would be the advantage from changing the thing with 're'?
dont even know what it means
The 're' adds a leading zero to series indices that are 1 digit long. For example, an index of '5' will be changed to '05', while an index of '15' will be left alone. If you don't want this behavior, then you can use
Code:
{author_sort}/{series:|| -} {series_index:|| -} {title} - {authors} - {isbn}
My question related to how the leading zero was being added. A different solution is to use a format specification that ensures that the series indices have a fixed look. For example,
Code:
{author_sort}/{series:|| -} {series_index:05.2f|| -} {title} - {authors} - {isbn}
will produce the following output for the given series indices:
1 -> 01.00
1.4 -> 01.40
10 -> 10.00
14.43 -> 14.43

Also note that your template will put an extra space after the slash if there is no series or series index, and will have an extra trailing - if there is no ISBN. You probably want to use
Code:
{author_sort}/{series:|| - }{series_index:|| - }{title} - {authors}{isbn:| - |}
As for why it works: if a template element is not empty, then the text after the first | is inserted before the value and the text after the second | is appended after the value. If the template element is empty, then no text is inserted or appended. Thus if a book has an ISBN, a " - " is inserted before it. If the book has no ISBN, then nothing is inserted.

Last edited by chaley; 07-30-2011 at 04:26 AM.
chaley is offline   Reply With Quote