View Single Post
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,476
Karma: 8025702
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