[% 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 => 'credits', label => l('Credited'), xpath => '//*[@tag="100"]|//*[@tag="110"]|//*[@tag="111"]' }, { 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 = ''; FOR subfield IN node.childNodes; NEXT UNLESS subfield.nodeName == "subfield"; code = subfield.getAttribute('code'); NEXT UNLESS code.match('[a-z]'); sf_raw = subfield.textContent; sf = subfield.textContent | html; term = term _ ' ' _ sf; qterm = qterm _ ' ' _ sf_raw; END; url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, ['page', 'expand']); author_type = label | html; '' _ term _ ' (' _ author_type _ '). '; END; END; %]
[% FOREACH author IN authors; NEXT UNLESS author.xpath; links = PROCESS build_author_links(xpath=author.xpath, label=author.label); IF links.match('\S') %] [% links %] [% END %] [% END %]