Quote:
Originally Posted by Gelina
I apologize for being an idiot - but I can't get that to work. I went into "Template Functions" and put the function name as my_seriesindex and your code as the program code, but I keep getting a compile error.
|
A general program mode template is a template, not a function. It is a complete template written in the template programming language. It must be the only thing in the template box.
Quote:
The entire template I've been using is:
Code:
{#booktype}/{author_sort:re([.]$,)}/{series}/{series_index:0>2s||. }{title} - {authors}
or
Code:
{#booktype}/{author_sort:re([.]$,)}/{series}/{series_index:0>4.1f||. }{title} - {authors}
|
You are currently using
single function mode templates. They are not the same as
template program mode templates or
general program mode templates.
The following GPM template should do what you want. It is not a particularly elegant solution, but it should be understandable.
Code:
program:
t_dot = '{#booktype}/{author_sort:re([.]$,)}/{series}/{series_index:0>4.1f||. }{title} - {authors}';
t_nodot = '{#booktype}/{author_sort:re([.]$,)}/{series}/{series_index:0>2s||. }{title} - {authors}';
t_noseries = t_nodot;
template = test(field('series'),
contains(field('series_index'),
'\.',
t_dot,
t_nodot),
t_noseries);
template(template)
You put the above into the box that currently contains the {...} stuff. You can define t_noseries to be a different template, the one that is used when the book does not have a series.