View Single Post
Old 03-06-2011, 10:35 AM   #9
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: 11,770
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Try:
Code:
{#gr_2read:'switch($, "Yes", "To Read", template("[[author_sort]]/[[series]]"))'}/{title} - {authors}
if the CC #gr_2read contains the word "Yes", the constant string "To Read" is returned. If the CC contains anything else (including nothing), the evaluation of the template is returned.

Note that the regexps used by switch are case sensitive, and that the string values of a bool column are Yes, No, and empty. IIRC, Yes and No are translatable, so if you are not running in English, check to see what the text says.

Starting in 0.7.48 (or maybe 47) you can avoid translation by using raw_field, with will return 'True', 'False', and 'None'.
Code:
program:
	strcat(
		switch(raw_field('#gr_2read'), 'True', 'To Read', template('[[author_sort]]/[[series]]')), 
		template('/{title} - {authors}')
	)
chaley is offline   Reply With Quote