View Single Post
Old 03-25-2015, 04:31 AM   #7
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,452
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by myki View Post
Thanks for your help, I like it clear and efficient
I have (I hope) a last improvement to do :
I need to make a custom field (#kobocollections), which content is feed by another custom field if not empty (#categorieperso), and a custom value if empty ({authors:sublist(0,1,&)}{series:| - |}).

I succeeded by using :
Code:
program:
	a = field('#categorieperso');
	b = template('{authors:sublist(0,1,&)}{series:| - |}');
	test(field('#categorieperso'), a, b)
FWIW: you could use
Code:
program:
	a = field('#categorieperso');
	b = template('{authors:sublist(0,1,&)}{series:| - |}');
	ifempty(a, b)
or
Code:
program:
	ifempty(
		field('#enum2'), 
		template('{authors:sublist(0,1,&)}{series:| - |}'))
Quote:
But can you explain to me why with this :
Code:
{#categorieperso:'ifempty($, template('{authors:sublist(0,1,&)}{series:| - |}'))'}
I get a template error formatter when my serie own a " ' " ??

Can you help me again, please ??
You cannot put { or } characters in a template program mode template. The substitutions indicated by the {} characters happen before the template program fragment is evaluated, confusing the template evaluator. In your case the apostrophe is being interpreted as a string delimiter, creating a syntax error. You must use general program mode when you wish to evaluate sub-templates.
chaley is offline   Reply With Quote