View Single Post
Old 04-01-2023, 04:21 AM   #550
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,458
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Code:
program:
	id = list_re($#admintags, ',', 'related:(\d+)', '\1');
	strcat('<a href="', 'calibre://book-details/My%20Books/',id, '">', 'Related Book','</a>')
This looks for related:x entries in #admintags, extracts x and then uses strcat to turn it into a link.

If there's multiple ids returned by the list_re how would I create a link for each one instead of calibre://book-details/My%20Books/x,y,z?
Something like this, suitably altered for your columns and for the formatting you want.
Code:
program:
	ids = list_re($tags, ',', '(.*)', '\1');
	links = '';
	for id in ids:
		links = links & strcat('<a href="', 'calibre://book-details/My%20Books/',id, '">', 
					'Related Book','</a>', ', ')
	rof;
# remove the trailing comma
	substr(links, 0, -1)
chaley is offline   Reply With Quote