View Single Post
Old 10-15-2011, 05:56 AM   #4
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,741
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Jade Aislin View Post
1) Is there a thread or link that I can go to learn more about composite columns and how to fiddle with the template? When I looked at different threads on composite columns before they never seemed to address what I wanted. I used the code you gave me, but I am unsure how to create them on my own.
I will use genre instead of Category, because that is what I have to test with.

Two suggestions:
1) the template language manual: http://manual.calibre-ebook.com/template_lang.html. Also see the template function reference manual: http://manual.calibre-ebook.com/template_ref.html
2) the techniques post at the top of this forum: https://www.mobileread.com/forums/sho...d.php?t=118563

What might not be obvious to you is that a composite column is a column that displays the result of evaluating a template. Thus any posts that describe templates are of use when considering composite columns.
Quote:
2) Is it possible to have the template only look for certain stories to display based off a higher heirarchy item? For example, (using the example I gave before fantasy.magic.dragons and fantasy.non-magic.dragons) could I create a composite column that would only display the last item of those tags that were under the magic item?
Starting to get complicated, but yes. For example, the following template finds all genres that begin with comics or history, then extracts the last item in each genre.
Code:
{#genre:'subitems(list_re($, ',', '^(comics|history)\.', ''), -1, 0)'}
To break the template apart, first note that it is using template program mode instead of single function mode (see the manual), which is required because we want one function to use the result of another function. The list_re reduces the list of genres to those that start with what is in the regular expression pattern (comics or history) and returns that list to the subitems function. Subitems then extracts the last item from each genre in that returned list.

Note that this template works with calibre 0.8.22 (the latest release) and later.
Quote:
3) Is it possible to create a composite column that would only display a higher up heirarchal item? For example, could it show the second heirarchy item such as magic and non-magic only?
I am not sure of the details of what you are asking for. If you want the second item for all genres, then use
Code:
{#genre:subitems(1,2)}
If you want to filter first by the first item in the hierarchy, then you would use something like the template above, changing the subitems() call as necessary.
chaley is offline   Reply With Quote