|
![]() |
|
Thread Tools | Search this Thread |
![]() |
#1 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Feb 2011
Device: kindle
|
How to build custom column based on other columne (if - then statement)
Hi there people
Background. I have a Kindle 2/3 and I am planning to let the Kindle Collection plugin handle my collections. The way I use kindle is that as soon as I am finished reading books in one collection I rename it on the kindle to x_NAME.... or X_NAME where NAME is the original collection name. This works fine and I can set the plugin to not do anything with collections starting with x_ However, the plugin will try to recreate the original collection when I run it again. So to handle this I am planning to also cater for the x_ named collection. To do that, I use the plugin to read all existing collections existing on kindle into a custom column called kindlecollections. Then I have another custom column called collectionname with following template {#universe:'ifempty($, field('author_sort'))'}{series:| - |} The template works the way I want. But does not check anything in #kindlecollections What I would like is for the #collectionname to check if #kindlecollections start with x_ or X_ If it does, copy the content of #kindlecollections to #collectionname If it doesn't, use {#universe:'ifempty($, field('author_sort'))'}{series:| - |} to populate #collectionname I have been playing with the template, but can't seem to get my head around it. Anyone able to help me? Or is it another way to do what I want? Cheers, Atle |
![]() |
![]() |
![]() |
#2 |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Feb 2011
Device: kindle
|
OK, was able to figure it out. Had some problems due to apostrophe, but following works for me:
{#kindlecollections:'contains($,'^x_*',field('#kin dlecollections'),"{#universe:'ifempty($, field('author_sort'))'}{series:| - |}")'} Cheers, Atle |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
If you want to nest templates or TPM expressions then you should use General Program Mode where no macro processing takes place. They are also easier to read when dealing with this level of complexity. Something like: Code:
program: u = ifempty(field('#universe'), field('author_sort')); s = finish_formatting(field('series'), '', ' - ', ''); kc = field('#kindlecollections'); contains(kc, '^x_*', kc, strcat(u, s)) FWIW: I suspect that the regexp you use in the 'contains' isn't what you really want. That regexp looks for a leading x followed by zero or more underscores. I thing you want '^x_', which is a leading x followed by an underscore. |
|
![]() |
![]() |
![]() |
#4 | |
Junior Member
![]() Posts: 6
Karma: 10
Join Date: Feb 2011
Device: kindle
|
Quote:
And it looks much simpler to use program: instead. So when I have time I will expand this to also strip out quotes. Currently that is not a problem since I have changed all my series to not include quotes.... Turns out that Kindle is not so happy with quotes (or the kindle collections plugin is not so happy) Next step is to verify that everything works properly and not screw up my kindle on the first run. Thanks a lot Cheers, Atle |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom Column Build from other Columns | Tanjamuse | Library Management | 7 | 10-16-2014 01:28 AM |
REQ: Template for custom column to calc # of Pgs based on traditional counts | jecilop | Library Management | 15 | 09-13-2014 07:04 PM |
Looking for how to create a custom column based on a tag | kaufman | Library Management | 10 | 02-12-2014 11:15 AM |
Custom column returns value based on value of another custom column? | calvin-c | Calibre | 3 | 09-14-2013 02:24 PM |
Using "Build column from other column" custom-column type | HFC3 | Library Management | 3 | 07-07-2013 03:11 AM |