View Single Post
Old 06-15-2012, 04:30 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: 12,461
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I think that the following does what you are looking for.
Code:
Ebooks/{tags:re([\.],/!)|!|}/{authors[0]}/{authors}/{series:subitems(0,1)||/}{series_index:0>5.2f| | - }{series:subitems(1,10)| | - }{title}
It puts the first (or only) component of the series between two slashes, then puts the second through last components between the series index and the title. If there is no series then the second slash is omitted. I added some spaces and dashes that you might not want.

Note that if there is only one component (no hierarchy), then the result is the series index followed by the title. If you want some text that indicates "no hierarchy", then use something like the following:
Code:
Ebooks/{tags:re([\.],/!)|!|}/{authors[0]}/{authors}/{series:subitems(0,1)||/}{series_index:0>5.2f| | - }{series:'ifempty(subitems($, 1,10), 'No Subseries')'| | - }{title}
This template uses template program mode for the series+subitems call so that the function calls can be nested.

If you want something that indicates "No series" as well, then use something like
Code:
Ebooks/{tags:re([\.],/!)|!|}/{authors[0]}/{authors}/{series:'ifempty(subitems($, 0,1), 'No Series')'||/}{series_index:0>5.2f| | - }{series:'ifempty(subitems($, 1,10), 'No Subseries')'| | - }{title}
BTW: It is much easier to test templates of this complexity using a "column built from other columns" instead of actually sending books to the device.
chaley is offline   Reply With Quote