Quote:
Originally Posted by ownedbycats
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?
|
You shouldn't need to duplicate the switch_if. I haven't tried to run this template but it should produce what you want:
Code:
program:
list_join(
', ',
## trimmed out other lines for length
if $publisher=='Archive of Our Own' then urls_from_identifiers('ao3:' & select($identifiers, 'ao3'), 1) fi,
', ',
if !$publisher=='FanFiction.net' then urls_from_identifiers('ffnet:' & select($identifiers, 'ffnet'), 1) fi,
',',
)