View Single Post
Old 10-15-2011, 09:15 PM   #5
Jade Aislin
Groupie
Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.Jade Aislin could sell banana peel slippers to a Deveel.
 
Posts: 164
Karma: 3100
Join Date: Sep 2011
Device: Kobo Auro H2O, PRS-T1
Smile

Quote:
Originally Posted by chaley View Post
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
I have skimmed over those sections before, but with the examples you gave, I think I am understanding it a little better. I'll look at them again.


Quote:
Originally Posted by chaley View Post
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.
You are right, for some reason, it was not obvious to me. Now I know.

Quote:
Originally Posted by chaley View Post
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.
That is almost exactly what I want. However, I want it to be more general. When I tried it, I found that I had to put in the subitem path. Using your 'comics' as an example, if I had a subitem book.comics and I wanted to get the last item for any genre that contained comics I had to write out book.comics. My problem is that I also want to be able to get the last subitems of newspaper.comics. I want to be able to get the last item from each genre no matter what the higher up subitems are (book or newspaper).

I hope that made sense. I will go over the links you sent me to see if I can figure it out.

Quote:
Originally Posted by chaley View Post
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.
This is exactly what I was asking about. Although, I wanted to grab the subitems in the third row, but this code worked.

Code:
 
{#maincategory:subitems(2,3)}
Thanks for all the help. Now I can get busy on organizing all my stories.

- Jade Aislin
Jade Aislin is offline   Reply With Quote