View Single Post
Old 10-22-2022, 05:12 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: 12,488
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Comfy.n View Post
edit: https://www.mobileread.com/forums/sh...d.php?t=288508 < this PI makes the VL values clickable
Assuming you use a composite column (column built from other columns) that behaves like tags, they are clickable without using the PI. Are you seeing something different?

And just for fun I made a composite column that lets you switch VLs by clicking the links in book details. The GPM template is:
Code:
program:
	res = '';
	for vl in virtual_libraries():
		if res then res = res & '<br>' fi;
		res = res & '<a href="calibre://search/_?encoded_virtual_library=' & to_hex(vl) & '">' & vl & '</a>'
	rof;
	res
The column definition is:
Click image for larger version

Name:	Clipboard01.png
Views:	90
Size:	16.5 KB
ID:	197304

What you see is:
Click image for larger version

Name:	Clipboard05.png
Views:	85
Size:	2.4 KB
ID:	197303

And for more fun, here is the template using python template mode (PTM), which will be much faster than the GPM template above:
Code:
python:
def evaluate(book, ctx):
	db = ctx.db.new_api
	return ('<br>'.join(
		[f'<a href="calibre://search/_?encoded_virtual_library={vl.encode().hex()}">{vl}</a>' 
		 for vl in db.virtual_libraries_for_books((book.id,))[book.id]
		]))
EDIT: corrections to the column setup and the python template

Last edited by chaley; 10-22-2022 at 05:45 AM. Reason: Fixes for column definition and python template
chaley is offline   Reply With Quote