View Single Post
Old 05-08-2023, 05:11 AM   #620
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,495
Karma: 8065348
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Also, a related question:

I have two identifiers, ao3 and ffnet. I'd like to change the order their links appear depending on the publisher.

Here's what I have:

Code:
program:
	list_join(
		 ', ',

## trimmed out other lines for length

		switch_if(
			$publisher=='Archive of Our Own', urls_from_identifiers('ao3:' & select($identifiers, 'ao3'), 1),
			$publisher=='FanFiction.net', urls_from_identifiers('ffnet:' & select($identifiers, 'ffnet'), 1),
			''
		), ',',

		switch_if(
			!$publisher=='Archive of Our Own', urls_from_identifiers('ao3:' & select($identifiers, 'ao3'), 1),
			!$publisher=='FanFiction.net', urls_from_identifiers('ffnet:' & select($identifiers, 'ffnet'), 1),
			''
		), ',',

	)

This gets the result I want:
- if both ids are available, both are listed
- If publisher is Archive of Our Own, the ao3 link appears first.
- If publisher is FanFiction.net, the ffnet link appears first.

But is this the best way to do this?
The template I posted doesn't give you what you want. It ignores the ordering request. What you did originally is a reasonable solution.
chaley is offline   Reply With Quote