View Single Post
Old 11-12-2013, 06:20 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,475
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Selecting the first genre from a list of them is a bit complicated. We must first be sure that we know what "first" means. You probably mean it to be the first displayed, so we need to sort the list (list_sort) because inside calibre its sort order isn't defined. We then must extract the first tag from the sorted list (sublist), and finally extract the last item from that first tag (list_item).

The following template in template program mode should work
Code:
{#genre:'list_item(sublist(list_sort($, 0, ','), 0, 1, ','), -1, '.')'}
We need to use template program mode because we are using the output of one function as the input for another, something that cannot be done in the simpler single function mode.
chaley is offline   Reply With Quote