View Single Post
Old 02-12-2025, 03:25 PM   #162
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,449
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Comfy.n View Post
Interesting updates, thank you! I noticed that running:

Code:
program: make_url_extended('https', 'en.wikipedia.org', '/w/index.php', 'search', field('author'))
returns slightly different URLs on Template Tester and L&F -> BD -> Custom search URL -> Template dialog:

on Template tester (good link):

https://en.wikipedia.org/w/index.php...B2+Machiavelli

on new Template dialog for custom search:

https://en.wikipedia.org/w/index.php...%2BMachiavelli
To be clear, you aren't testing the new book details custom column URL feature. Instead you are testing the long-existing L&F / Book details custom authors rule.

The problem is that the L&F / Book details dialog *knows* it is for authors only, and in fact doesn't even have the rest of the metadata. Historically, because L&F / Book details knows it is for authors, to simplify things for the expected use case the author is URL-encoded before it gets to the template. Thas is why the template
Code:
https://www.wikipedia.org/w/index.php?search={author}
works there; the interpolated 'author' is already URL-encoded. This can't be changed without breaking existing custom author links. Note also that you can't make decisions in the template such as "if author == 'John Doe' then" because the author will already be encoded as 'John+Doe'.

If you want to use make_url_extended() there then you must use the variant where you control whether the query value is encoded (again) during URL construction.
Code:
program:
	qs = query_string('search', $author, 2);
	make_url_extended('https', 'wikepedia.com', '/w/index.php', qs)
You will see in the L&F / Book details template tester result that the author, Niccolò Machiavelli, is URL-encoded. In the normal template tester, where the original metadata is being used, it won't be URL-encoded.

This discrepency is why the new custom column link generation feature offers the item value unencoded, URL-encoded with '+' for spaces, and URL-encoded with %20 for spaces.

Bottom line: you can't use the same template in L&F/ BD as you use in the new custom column web link feature.
chaley is offline   Reply With Quote