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-23-2025, 07:37 PM   #1
Thinkling
Junior Member
Thinkling began at the beginning.
 
Thinkling's Avatar
 
Posts: 5
Karma: 10
Join Date: May 2025
Location: Pennsylvania, USA
Device: Calibre
Sort options for Publisher field similar to Author field?

One of the tweaks that can by highly customized in Calibre is how to sort names in the Author column. What titles/honoraries to ignore, ignoring leading articles, etc.

I would like to be able to implement this last feature, ignoring leading articles (a/an, the) in the Publisher field's names as well. Currently names like "The Atlantic" do not ignore the leading article and sort as starting with "T" and not starting with "A". But this can be done in the Author field.

My current workaround is to give names like "Atlantic, The". But this is clunky and unattractive. Any pointers as to how to implement this feature? Are there plug-ins which do this?

Thanks in advance,
T
Thinkling is offline   Reply With Quote
Old 05-23-2025, 11:37 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,242
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Create a custom column built from other columns, then use a template to format the publisher name however you like.
kovidgoyal is offline   Reply With Quote
Old 05-24-2025, 09:54 PM   #3
Thinkling
Junior Member
Thinkling began at the beginning.
 
Thinkling's Avatar
 
Posts: 5
Karma: 10
Join Date: May 2025
Location: Pennsylvania, USA
Device: Calibre
Thumbs up

Quote:
Originally Posted by kovidgoyal View Post
Create a custom column built from other columns, then use a template to format the publisher name however you like.
Thank you Kovid. I have never used templates before but I know there is a lot of documentation about them I can use to get up to speed.

Thinkling is offline   Reply With Quote
Old 05-25-2025, 05:38 AM   #4
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,358
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
The template function swap_around_articles() should do what you want. If putting the article on the end is all you want then this template should do
Code:
{publisher:swap_around_articles()}
Note that it uses a semicolon instead of a comma because publisher names can include commas.

If you want a comma instead of a semicolon then this template should do:
Code:
{publisher:'re(swap_around_articles($, ','), ';', ',')'}
This converts all semicolons to commas.

Last edited by chaley; 05-25-2025 at 06:04 AM. Reason: change "formatter function" to "template function"
chaley is offline   Reply With Quote
Old 05-26-2025, 11:32 AM   #5
Thinkling
Junior Member
Thinkling began at the beginning.
 
Thinkling's Avatar
 
Posts: 5
Karma: 10
Join Date: May 2025
Location: Pennsylvania, USA
Device: Calibre
Quote:
Originally Posted by chaley View Post
The template function swap_around_articles() should do what you want. If putting the article on the end is all you want then this template should do
Code:
{publisher:swap_around_articles()}
Note that it uses a semicolon instead of a comma because publisher names can include commas.

If you want a comma instead of a semicolon then this template should do:
Code:
{publisher:'re(swap_around_articles($, ','), ';', ',')'}
This converts all semicolons to commas.
I made a custom column and used this template. The sorting works fine, but the original issue still stands: it's displayed as (e.g.) "Atlantic; The". This does seem to jive with the documentation for that template.

I think I will need to write/extend a template to format the entry, like Kovid mentioned.
Thinkling is offline   Reply With Quote
Old 05-26-2025, 12:09 PM   #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: 12,358
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Thinkling View Post
I made a custom column and used this template. The sorting works fine, but the original issue still stands: it's displayed as (e.g.) "Atlantic; The". This does seem to jive with the documentation for that template.
Yes it does. The output of the template becomes the text of the column. The documentation says that the template returns its argument with articles moved to the end. That is what you are seeing.
Quote:
I think I will need to write/extend a template to format the entry, like Kovid mentioned.
Columns sort on "what you see" except for columns that have a "look somewhere else" for sort order, e.g., title, authors, and series. There is no mechanism other than changing calibre's code to add look-aside sort functionality for other fields.

When Kovid suggested a custom column he was suggesting exactly what I showed you. Instead of sorting on Publisher you sort on the custom column to get the order you want. The Publisher field remains "The Atlantic". The custom field is "Atlantic; The".

You don't need to show the custom column in the book list to sort on it. Hide the custom column then use the "sort by" tool to sort the library. If you do this often enough then you can use the Action Chains plugin to create a shortcut to do the sort.

I could in theory add a "sort template" to custom columns, which would give you a mechanism to sort custom columns on something different from what you see. I'm not convinced the added functionality is worth the development effort. I'm also not sure the performance would be adequate.
chaley is offline   Reply With Quote
Old 05-26-2025, 03:31 PM   #7
Thinkling
Junior Member
Thinkling began at the beginning.
 
Thinkling's Avatar
 
Posts: 5
Karma: 10
Join Date: May 2025
Location: Pennsylvania, USA
Device: Calibre
Quote:
Originally Posted by chaley View Post
Yes it does. The output of the template becomes the text of the column. The documentation says that the template returns its argument with articles moved to the end. That is what you are seeing.

Columns sort on "what you see" except for columns that have a "look somewhere else" for sort order, e.g., title, authors, and series. There is no mechanism other than changing calibre's code to add look-aside sort functionality for other fields.

When Kovid suggested a custom column he was suggesting exactly what I showed you. Instead of sorting on Publisher you sort on the custom column to get the order you want. The Publisher field remains "The Atlantic". The custom field is "Atlantic; The".

You don't need to show the custom column in the book list to sort on it. Hide the custom column then use the "sort by" tool to sort the library. If you do this often enough then you can use the Action Chains plugin to create a shortcut to do the sort.

I could in theory add a "sort template" to custom columns, which would give you a mechanism to sort custom columns on something different from what you see. I'm not convinced the added functionality is worth the development effort. I'm also not sure the performance would be adequate.
Success! Thanks chaley for the clarification.

For other users' reference: I kept the column I made above, and hid it. Then just added the Sort by drop down tool to my toolbar. Selecting my new invisible column from that drop down did the trick.
Thinkling is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
on main screen the field AUTHOR is filled in but AUTHOR SORT is blank xenduro Calibre 7 12-30-2024 08:06 PM
Finding books with author's name in the publisher field ownedbycats Library Management 2 05-15-2022 06:38 PM
Author field update and author sort derangedhermit Calibre 4 01-23-2013 04:10 AM
Author sort field with several authors vRiki Library Management 6 11-27-2012 02:05 PM
Author Sort Field in Edit Meta Information Window RoninTech Calibre 4 11-13-2008 04:08 AM


All times are GMT -4. The time now is 12:04 PM.


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