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 05-18-2021, 09:48 AM   #1
blar
Junior Member
blar began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2021
Device: Kobo Clara HD
Column from multiples, with added prefixes

So, I had a tags field with multiple categories of tags. I decided it would be more useful in sorting to split this out into custom tag-like columns for each category. However, I still want a 'tags' style column that combines them all for viewing and for generating Kobo collections. I also want to add the prefixes I was using before.

I have zero experience with coding, so I am fumbling through this stuff. I tried this out first, and it seemed okay enough.

Code:
{tags:||, }{#ratingtags:||, }{#datetags:||, }{#authortags:||, }{#awardtags:||, }{#listtags:||, }{#wordcounttags}
However, when I tried to add in my prefixes to this template, I discovered they don't work for multiple tags, only for the first one in the list. Author, award, list, and word count tags all use prefixes. For example, this is what I used for my author tags (which are tags relating to authors, e.g. nationality, not author names, by the way).

Code:
{#authortags:|author.|, }
I found out a better way to do it thanks to a search and oren64's answer, adjusted for my names and prefixes as follows.

Code:
program:strcat(test(field('#authortags'), "author.", ""),re(field('#authortags'),", ", ", author."))
But I don't know how to combine this with the other columns, as just adding in the templates from the first example doesn't work. I've tried reading the documentation but my understanding breaks down at the modes part. I guess I could make more custom columns for each using what I know works and then combine them with templates, but that seems excessive and I'm sure there's a "right" way to do this.
blar is offline   Reply With Quote
Old 05-18-2021, 05:08 PM   #2
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,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
You can do this with a template like the following:
Code:
program:
	result = '';
	result = list_union(result, list_re($tags, ',', '(.+)', 'tags.\1'), ',');
	result = list_union(result, list_re($#authortags, ',', '(.+)', 'authortags.\1'), ',');
	result = list_union(result, list_re($#ratingtags, ',', '(.+)', 'ratingtags.\1'), ',');
	result = list_union(result, list_re($#awardtags, ',', '(.+)', 'awardtags.\1'), ',');
Each of the "result = list_union" lines adds items from a column prefixed with whatever you put in front of ".\1". You will need to add more lines to deal with the other columns, following the pattern.

This template requires calibre 5.14 or later.

NB: You can edit the template for the tags-like column using F2 (or whatever the edit key is on your system) in the library view.
chaley is offline   Reply With Quote
Advert
Old 05-19-2021, 09:18 AM   #3
blar
Junior Member
blar began at the beginning.
 
Posts: 9
Karma: 10
Join Date: May 2021
Device: Kobo Clara HD
Quote:
Originally Posted by chaley View Post
You can do this with a template like the following:

[...]

NB: You can edit the template for the tags-like column using F2 (or whatever the edit key is on your system) in the library view.
This does exactly what I wanted, thanks so much! And thanks for the shortcut tip---I'd been going through the trouble of editing the column and restarting, and now I know the better way.
blar is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Added column? Can I set date when book added to library? fitzhugh Calibre 4 06-03-2012 05:42 PM
Custom column for date added Gunnerp245 Calibre 2 07-08-2011 04:39 PM
New added column is not shown as metadata Tolkamp Library Management 5 06-18-2011 08:52 AM
Custom column for book added gandor62 Library Management 1 03-01-2011 06:58 AM
stuck with recently added column holterzoff Calibre 3 11-07-2010 06:47 AM


All times are GMT -4. The time now is 03:25 AM.


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