Quote:
Originally Posted by Mister L
I am trying to create a custom column from tags to manage collections on the kobo, but no values are being added (neither in the column, nor in the collections on the device). Maybe it's because I'm trying to use regex in the program code?
When I add a book recommended by someone, I add a tag "reco [name]". So for instance "reco Martha Wells". I would like the copy this tag to the "reco" column to use as a collection column.
I created a "reco" column from other columns, acts like tags:
Code:
program:
switch_if(
$tags == 'reco (.*)', 'reco \1',
'')
But this "reco" column is never filled. Am I missing a step somewhere?
Part two, would it be possible to also, automatically add any books with a value in the "reco" column to a general collection named "friends recos"?
Could I do that with something like this, either in the column or in the collections model in the KoboTouchExtended Driver?
Code:
program:
switch_if(
$tags == 'reco (.*)', 'reco \1',
$tags == 'reco (.*)', 'recos amis',
'')
|
The expression you are using won't work in the template language. I didn't add perl syntax.
Also, if I am understanding you correctly there can be multiple 'reco XX' tags attached to a book. In this case you must process the tags one at a time. This template does that, and your case 2.
Code:
program:
result = '';
for t in $tags:
if substr(t, 0, 5) == 'reco ' then
result = list_join(',', result, ',', t & ',' & 'recos amis', ',')
fi
rof;
result
Alternatively you could do it in python template mode using a list comprehension that filters out anything not starting with 'reco '. Try that if you know python.