[%- PROCESS "opac/parts/relators.tt2"; authors = [ { type => 'author', label => l('Author'), xpath => '//*[@tag="100"]|//*[@tag="110"]|//*[@tag="111"]' }, { type => 'added', label => l('Added Author'), xpath => '//*[@tag="700"]|//*[@tag="710"]|//*[@tag="711"]' }, { type => 'cast', label => l('Cast'), xpath => '//*[@tag="508"]' }, { type => 'notes', label => l('Author Notes: '), xpath => '' # Comes from added content... } ]; BLOCK build_author_links; FOR node IN ctx.marc_xml.findnodes(xpath); term = ''; qterm = ''; iprop = ''; tlabel = ''; graphics = []; FOR subfield IN node.childNodes; NEXT UNLESS subfield.nodeName == "subfield"; code = subfield.getAttribute('code'); IF code == '4'; relcode = subfield.textContent.substr(0,3); tlabel = relators.$relcode || label; END; IF code == '6'; linked_fields = [subfield.textContent()]; target_field = node.getAttribute('tag'); get_linked_880s; END; NEXT UNLESS code.match('[a-z]'); sf = subfield.textContent | html; term = term _ ' ' _ sf; IF code.match('[acdq]'); sf_raw = subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ' '); qterm = qterm _ ' ' _ sf_raw; END; END; url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, ['page', 'expand']); author_type = (tlabel || label) | html; # schema.org changes IF type == 'author'; iprop = ' itemprop="accountablePerson"'; ELSIF type == 'added'; iprop = ' itemprop="contributor"'; END; '' _ term.replace('^\s+', '') _ ''; FOREACH link880 IN graphics; diratt = ''; IF link880.dir; diratt = ' dir="' _ link880.dir _ '"'; END; ' '; link880.value | html; ''; END; ' (' _ author_type _ '). '; END; END; %]
[%- FOREACH author IN authors; NEXT UNLESS author.xpath; links = PROCESS build_author_links( xpath=author.xpath, label=author.label, type=author.type ); IF links.match('\S') %] [% links %] [%- END %] [%- END %]