Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-18-2023, 11:27 AM   #16
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
Quote:
Originally Posted by chaley View Post
Enhancement: the template could verify that the id actually exists, which can happen because of an input error or deleting a book. If the id doesn't exist then a message is displayed. Something like this:
Code:
program:
	j = '';
	for id in $#mytextmult:
		if j then j = j & ', ' fi;
		id_exists = book_count('id:' & id, 0);
		if id_exists != 1 then
			j = j & 'No such id ' & id
		else
			j = j & '<a href="' & 'calibre://show-book/_hex_-' &
				to_hex(current_library_name()) & '/' & id & '">' & id & '</a>'
		fi
	rof
which produces this:
Attachment 196676
Hi chaley

I get this error

Code:
VORLAGENFEHLER The book_count() function cannot be used in a composite column
Click image for larger version

Name:	Screenshot 2023-03-18 162013.jpg
Views:	86
Size:	62.4 KB
ID:	200427

Any idea?

Thank you!
Wiggo is offline   Reply With Quote
Old 03-18-2023, 01:17 PM   #17
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,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Wiggo View Post
Hi chaley

I get this error

[CODE]VORLAGENFEHLER The book_count() function cannot be used in a composite column

Any idea?

Thank you!
The template database functions can be very slow. To avoid surprises and bug reports, I decided the user must specifically allow them, so the person can see the difference in performance.

See Preferences / Tweaks / Allow template database functions in composite columns (ID: allow_template_database_functions_in_composites)
chaley is offline   Reply With Quote
Advert
Old 03-18-2023, 01:31 PM   #18
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
Wiggo is offline   Reply With Quote
Old 03-18-2023, 01:56 PM   #19
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
Is there a possibility that the links also works "ouside" of the current view?
If the book is not listed in the view, the linking doesn't work

Edit: re-read the manual - not possible

Last edited by Wiggo; 03-18-2023 at 02:02 PM.
Wiggo is offline   Reply With Quote
Old 03-18-2023, 02:32 PM   #20
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,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Wiggo View Post
Is there a possibility that the links also works "ouside" of the current view?
If the book is not listed in the view, the linking doesn't work

Edit: re-read the manual - not possible
Why not? The documentation says that if the book isn't in the current VL then the VL is cleared. If specify a VL and the book isn't in that VL then the VL is ignored.
chaley is offline   Reply With Quote
Advert
Old 03-19-2023, 04:20 AM   #21
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
hmm.. you're right. I should concentrate again more while reading.

Anyhow. I don't use VLs.
When I search for "same author" then clicking on a related link doesn't lead to the book of a different author. But if I create a VL from the search, then it works.
Wiggo is offline   Reply With Quote
Old 03-19-2023, 06:55 AM   #22
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,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I understand what is happening. Finding similar authors does a search. That search is still in effect when you click the link, and it is applied to the results. If the book "selected" by clicking the link doesn't match the search then it isn't shown.

It isn't clear to me that a show_book link should preserve/honor the search, but that is a different question.

There are two solutions:
  • Force the "click" to clear the search by specifying a non-existent VL. This will of course clear any VL as well. This template (python) does that.
    Code:
    python:
    def evaluate(book, context):
    	cache = context.db.new_api
    	ids = book.get('#mytextmult', [])
    	answer = []
    	for id_ in ids:
    		if cache.has_id(int(id_)):
    			answer.append(f'<a href="calibre://show-book/_/{id_}?virtual_library=+@+@">{id_}</a>')
    		else:
    			answer.append(f"Book id {id_} doesn't exist")
    	return ', '.join(answer)
  • Use a search link instead of a show link.
    Code:
    python:
    def evaluate(book, context):
    	cache = context.db.new_api
    	ids = book.get('#mytextmult', [])
    	answer = []
    	for id_ in ids:
    		if cache.has_id(int(id_)):
    			answer.append(f'<a href="calibre://search/_?q=id:={id_}">{id_}</a>')
    		else:
    			answer.append(f"Book id {id_} doesn't exist")
    	return ', '.join(answer)
As before, you must change the name #mytextmult to match your column lookup name.

Python templates don't require the tweak.
chaley is offline   Reply With Quote
Old 03-19-2023, 12:13 PM   #23
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,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by chaley View Post
It isn't clear to me that a show_book link should preserve/honor the search, but that is a different question.
Kovid accepted a fix. If the target book is not in the search results then the search is cleared. Then if the target book is not in the VL the the VL is cleared.

The original template works with these changes, which are now in calibre source.
chaley is offline   Reply With Quote
Old 03-19-2023, 01:10 PM   #24
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
Thank you so much chaley!

Is there any difference in terms of e.g. perfomance between the 3?
Which one would you choose?

Edit: ahh, with python the view is always cleared.

Last edited by Wiggo; 03-19-2023 at 01:13 PM.
Wiggo is offline   Reply With Quote
Old 03-19-2023, 01:29 PM   #25
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,336
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Wiggo View Post
Is there any difference in terms of e.g. perfomance between the 3?
Which one would you choose?
The Python templates are *much* faster than the GPM templates. I would pick one of them. However, that might affect how you can maintain them.
Quote:
Edit: ahh, with python the view is always cleared.
The templates I provided don't take into consideration the fix I made (in source but not released). They both will clear a virtual library. The search version shows only the requested book (the result of the search).

Given my fix, I would use a modified version of the first template that generates show-book links. It is functionally equivalent to the original GPM template, including not clearing searches, but much faster.
Code:
python:
def evaluate(book, context):
	cache = context.db.new_api
	ids = book.get('#mytextmult', [])
	answer = []
	for id_ in ids:
		if cache.has_id(int(id_)):
			answer.append(f'<a href="calibre://show-book/_/{id_}">{id_}</a>')
		else:
			answer.append(f"Book id {id_} doesn't exist")
	return ', '.join(answer)
chaley is offline   Reply With Quote
Old 03-19-2023, 01:36 PM   #26
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
Thanks again!

I will wait for the next release and try this modified python one.
Wiggo is offline   Reply With Quote
Old 04-11-2023, 02:38 PM   #27
Wiggo
Leftutti
Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.Wiggo ought to be getting tired of karma fortunes by now.
 
Wiggo's Avatar
 
Posts: 549
Karma: 1717097
Join Date: Feb 2019
Location: Bavaria
Device: iPad Pro, Kobo Libra 2
Works like a charm - thank you chaley!
Wiggo is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to style (CSS) Custom columns/fields in Book details pane? What are their IDs? 01100001 Library Management 4 09-16-2022 11:06 AM
book details pane tracis035 Calibre 7 11-04-2016 12:00 AM
Is there a way to change the color of the clickable links in the book details pane? nalyd Calibre 3 07-08-2016 02:38 AM
Calibre:Book Cover size in Book Details side pane & Edit Metadata Individually window Volfer Calibre 3 01-05-2016 01:56 PM


All times are GMT -4. The time now is 11:16 PM.


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