Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 10-03-2013, 08:15 PM   #1
BeeTee-Ess
Addict
BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.
 
BeeTee-Ess's Avatar
 
Posts: 306
Karma: 679580
Join Date: Dec 2011
Location: Brisbane, Australia
Device: K3, K4NT, KPW2, Voyage, iP4, iP6, iPad Mini, HP TouchPad, Kobo Mini
Template for custom column

I am trying to create a Calibre custom column built from the Author Sort field, using the first (or only) author's name.

Can someone help me with the template for that please.
BeeTee-Ess is offline   Reply With Quote
Old 10-03-2013, 09:28 PM   #2
Adoby
Handy Elephant
Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.
 
Adoby's Avatar
 
Posts: 1,736
Karma: 26785668
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Thinkpad E595, Ubuntu Mate, Huawei Mediapad 5, Bouye Likebook Plus
{author_sort:list_item(0,&)}
Adoby is offline   Reply With Quote
Advert
Old 10-04-2013, 01:41 AM   #3
BeeTee-Ess
Addict
BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.
 
BeeTee-Ess's Avatar
 
Posts: 306
Karma: 679580
Join Date: Dec 2011
Location: Brisbane, Australia
Device: K3, K4NT, KPW2, Voyage, iP4, iP6, iPad Mini, HP TouchPad, Kobo Mini
Thank you, Adoby.
BeeTee-Ess is offline   Reply With Quote
Old 10-04-2013, 04:59 AM   #4
BeeTee-Ess
Addict
BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.
 
BeeTee-Ess's Avatar
 
Posts: 306
Karma: 679580
Join Date: Dec 2011
Location: Brisbane, Australia
Device: K3, K4NT, KPW2, Voyage, iP4, iP6, iPad Mini, HP TouchPad, Kobo Mini
Hello Adoby...

Please bear with me again. That is the first time I have used templates.

I am trying to extend the template above to replace the comma in the author_sort field with a semi-colon, so that Smith, Bill becomes Smith; Bill.

I assume that I need to use the re function, and came up with:

{re({author_sort:list_item(0,&)},,,}

but I expect I shall need to use some sort of escape character to distinguish the pattern argument comma from the separator commas between the function arguments.

Then, I am uncertain how I should combine the two functions, once I have expressed the re function correctly.

Just applying the initial template you provided has shown me what a time-saver they can be, and I want to become more fluent in their use.
BeeTee-Ess is offline   Reply With Quote
Old 10-04-2013, 05:19 AM   #5
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,740
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by BeeTee-Ess View Post
Hello Adoby...

Please bear with me again. That is the first time I have used templates.

I am trying to extend the template above to replace the comma in the author_sort field with a semi-colon, so that Smith, Bill becomes Smith; Bill.

I assume that I need to use the re function, and came up with:

{re({author_sort:list_item(0,&)},,,}

but I expect I shall need to use some sort of escape character to distinguish the pattern argument comma from the separator commas between the function arguments.

Then, I am uncertain how I should combine the two functions, once I have expressed the re function correctly.

Just applying the initial template you provided has shown me what a time-saver they can be, and I want to become more fluent in their use.
You can't nest template functions when using single function mode, which is what is used in the template Adoby gave you. You must use one of the other two modes, template program mode or general program mode. Which you pick depends on what you are trying to do, where the template will be used, and the complexity of the template.

I would use general program mode because this template will be used in a custom column. GPM templates used in custom columns are compiled and run significantly faster than the other kinds, which is important when browsing large libraries containing such columns.

A GPM template to do what you want is:
Code:
program: 
	asort = list_item(field('author_sort'), 0, '&');
	re(asort, ',', ';')
For completeness, the template in TPM is
Code:
{author_sort:'re(list_item($, 0, '&'), ',', ';')'}
chaley is offline   Reply With Quote
Advert
Old 10-04-2013, 08:55 PM   #6
BeeTee-Ess
Addict
BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.BeeTee-Ess ought to be getting tired of karma fortunes by now.
 
BeeTee-Ess's Avatar
 
Posts: 306
Karma: 679580
Join Date: Dec 2011
Location: Brisbane, Australia
Device: K3, K4NT, KPW2, Voyage, iP4, iP6, iPad Mini, HP TouchPad, Kobo Mini
Wow, chaley...

I've a lot to learn.

Thanks for your input.
BeeTee-Ess is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Plugboard, template, and custom composite column recipes chaley Library Management 976 Yesterday 06:29 PM
Custom column returns value based on value of another custom column? calvin-c Calibre 3 09-14-2013 02:24 PM
Custom yes/no column built from long text column Philantrop Library Management 7 03-23-2013 07:44 PM
[Custom Column - Composite] Template Help Requested Ealdwulf Library Management 2 06-16-2012 04:58 AM
Help with template for custom column from tags africalass Library Management 2 07-16-2011 11:47 AM


All times are GMT -4. The time now is 11:37 PM.


MobileRead.com is a privately owned, operated and funded community.