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 12-02-2023, 05:02 PM   #1
Midge
Junior Member
Midge began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2023
Location: United Kingdom
Device: Kobo Aura One/Kobo App on Android 14
Hierarchical Custom Composite Columns

I have been successful in creating a custom column that combines other columns. For that I used the one that acts like tags. This is the template:
{#series1:||,}{#series2:||,}{#series3}.

However, when I try to proceed with making the custom column hierarchical, it does not show up in custom metadata and the tags are not draggable.
For example, this is a previous column that works:
Click image for larger version

Name:	Hierarchical.png
Views:	49
Size:	4.7 KB
ID:	205015
and my current one which does not:
Click image for larger version

Name:	Not Hierarchical.png
Views:	48
Size:	3.5 KB
ID:	205016

Is creating a hierarchy something that you cannot do with custom composite columns, or am I missing something?
Thanks
Midge is offline   Reply With Quote
Old 12-04-2023, 12:50 AM   #2
kjdavies
Zealot
kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.
 
Posts: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
At a guess...

The delimiter for hierarchical tag browser entries is '.', not ','. And ending with '.' causes the hierarchy to break.

That is, "A,B,C." gives you an entry that is "A,B,C."

If instead you do

{#series1:||.}{#series2:||.}{#series3}

You should find it works. Notice that I did not include the '.' at the end of the template. Having '.' at the end of the template forces the result to be treated as a non-hierarchical value. In my test I used a mix of custom and built-in fields:

{#titlecount:||.}{#pagecount:||.}{series:||.}{#pub series:||.}{#pubseries_index}

giving me
  • 1
    • 10
      • hf
        • 119222
        • 119223

With the trailing '.', I get
  • 1.10.hf.119222.
  • 1.10.hf.119223.

Which brings up another observation: this works if and only if your last entry in the template exists. If it doesn't, but one or more of the entries ahead of it does, then you end up with a spurious trailing '.'.
kjdavies is offline   Reply With Quote
Advert
Old 12-04-2023, 12:52 AM   #3
kjdavies
Zealot
kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.
 
Posts: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by kjdavies View Post
{#titlecount:||.}{#pagecount:||.}{series:||.}{#pub series:||.}{#pubseries_index}
Curious. I see '#pub series' in the post, but I wrote that without the space.

Perhaps different markup...

Code:
{#titlecount:||.}{#pagecount:||.}{series:||.}{#pubseries:||.}{#pubseries_index}
Yeah, that looks like it works right.
kjdavies is offline   Reply With Quote
Old 12-04-2023, 02:39 AM   #4
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 993
Karma: 6417070
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by kjdavies View Post
Curious. I see '#pub series' in the post, but I wrote that without the space.
I have typed images, not im ages in this post:

https://www.mobileread.com/forums/sh...postcount=1166

However I couldn't get rid of that space for the life of me, lol.
Comfy.n is offline   Reply With Quote
Old 12-04-2023, 03:28 AM   #5
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,567
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by kjdavies View Post
Code:
{#titlecount:||.}{#pagecount:||.}{series:||.}{#pubseries:||.}{#pubseries_index}
Yeah, that looks like it works right.
Code boxes are also easier to read and copy from, especially when the poster uses a font like TNR.

BR
BetterRed is offline   Reply With Quote
Advert
Old 12-04-2023, 06:34 AM   #6
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 kjdavies View Post
Curious. I see '#pub series' in the post, but I wrote that without the space.

Perhaps different markup...

Code:
{#titlecount:||.}{#pagecount:||.}{series:||.}{#pubseries:||.}{#pubseries_index}
Yeah, that looks like it works right.
This avoids any extraneous periods by including a preceeding dot only if the column has a value:
Code:
{#titlecount:}{#pagecount:|.|}{series:|.|}{#pubseries:|.|}{#pubseries_index|.|}
However, I prefer this GPM template that (I think) makes the intentions explicit.
Code:
program:
	list_join('.', $#titlecount, '.', $#pagecount, '.', $series, '.',$#pubseries, '.', $#pubseries_index, '.')
The above can be written as a TPM template if it is embedded with other template expressions:
Code:
{:'list_join('.', $#titlecount, '.', $#pagecount, '.', $series, '.',$#pubseries, '.', $#pubseries_index, '.')'}
chaley is offline   Reply With Quote
Old 12-04-2023, 09:27 AM   #7
Midge
Junior Member
Midge began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2023
Location: United Kingdom
Device: Kobo Aura One/Kobo App on Android 14
Thanks

Quote:
Originally Posted by kjdavies View Post
Curious. I see '#pub series' in the post, but I wrote that without the space.

Perhaps different markup...

Code:
{#titlecount:||.}{#pagecount:||.}{series:||.}{#pubseries:||.}{#pubseries_index}
Yeah, that looks like it works right.
Thanks for your help. The '.' instead of ',' thing should have been obvious to me. I still don't seem to be able to get it to work though. I figure it is probably something wrong with the columns that I am trying to combine. Honestly I'm not very good at this sort of thing.
Midge is offline   Reply With Quote
Old 12-06-2023, 01:03 AM   #8
kjdavies
Zealot
kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.
 
Posts: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by chaley View Post
This avoids any extraneous periods by including a preceeding dot only if the column has a value:
Code:
{#titlecount:}{#pagecount:|.|}{series:|.|}{#pubseries:|.|}{#pubseries_index|.|}
However, I prefer this GPM template that (I think) makes the intentions explicit.
Code:
program:
	list_join('.', $#titlecount, '.', $#pagecount, '.', $series, '.',$#pubseries, '.', $#pubseries_index, '.')
The above can be written as a TPM template if it is embedded with other template expressions:
Code:
{:'list_join('.', $#titlecount, '.', $#pagecount, '.', $series, '.',$#pubseries, '.', $#pubseries_index, '.')'}
How about

Code:
program:
    '.'.join(filter(None, ($#titlecount,$#pagecount,$series,$#pubseries,$#pubseries_index)))
? I think this should make a string concatenating only the non-None values in the list, and prevent leading or trailing '.'.
kjdavies is offline   Reply With Quote
Old 12-06-2023, 06:09 AM   #9
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 kjdavies View Post
How about

Code:
program:
    '.'.join(filter(None, ($#titlecount,$#pagecount,$series,$#pubseries,$#pubseries_index)))
? I think this should make a string concatenating only the non-None values in the list, and prevent leading or trailing '.'.
Problem: that intermixes python and the GPR template language. The template should be rewritten as
Code:
python:
def evaluate(book, context):
    vals = (filter(
                None, 
                (
                    book.get('#myint2'), 
                    book.get('#pagecount'), 
                    book.get('series'), 
                    book.get('#series'),
                    book.get('#series_index')))
                )
    vals = ((str(v) if isinstance(v, (int, float)) else v) for v in vals)
    return '.'.join(vals)
Note: the list_join() template function ignores empty values, not adding them to the result list. None won't be encountered unless you use raw_field() or $$#.
chaley is offline   Reply With Quote
Old 12-08-2023, 02:37 AM   #10
kjdavies
Zealot
kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.kjdavies is no e-book dilettante.
 
Posts: 109
Karma: 53342
Join Date: Jun 2013
Device: Sony PRS-600
Quote:
Originally Posted by chaley View Post
Problem: that intermixes python and the GPR template language. The template should be rewritten as
Code:
python:
def evaluate(book, context):
    vals = (filter(
                None, 
                (
                    book.get('#myint2'), 
                    book.get('#pagecount'), 
                    book.get('series'), 
                    book.get('#series'),
                    book.get('#series_index')))
                )
    vals = ((str(v) if isinstance(v, (int, float)) else v) for v in vals)
    return '.'.join(vals)
Note: the list_join() template function ignores empty values, not adding them to the result list. None won't be encountered unless you use raw_field() or $$#.
My bad, I should've looked it up. I'd assumed list_join was a Python function.

Looking at the documentation, the semantics of list_join seems odd to me... but I think I see now how it works.
kjdavies is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Composite columns and identifiers ownedbycats Library Management 15 05-26-2022 02:32 PM
Quickview and composite columns ownedbycats Library Management 2 12-25-2020 04:43 PM
[Library Closed Plugin] Save Composite Custom Columns chaley Plugins 22 04-11-2020 07:09 AM
Question about hierarchical columns... dkplayaclub Library Management 14 06-27-2016 04:31 PM
composite custom columns sorted numerically Doug-W Library Management 2 02-18-2011 02:16 AM


All times are GMT -4. The time now is 04:33 AM.


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