Difference between revisions of "Template:PrintAuthorsArrayLastNameCommaFirstName"

From Encyclopedia of Scientonomy
Jump to navigation Jump to search
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
This template is used to convert an array of author names like "Thomas Kuhn, Imre Lakatos, Larry Laudan" into "Kuhn, Thomas; Lakatos, Imre; Laudan, Larry". If there are more than three authors, the "Kuhn, Thomas ''et al.'' will be returned.
+
This template is used to convert an array of author names like "Thomas Kuhn, Imre Lakatos, Larry Laudan" into a ''pretty'' list of "Kuhn, Thomas; Lakatos, Imre and Laudan, Larry". If there are more than three authors, the "Kuhn, Thomas ''et al.''" will be returned.
  
Parameters:
+
'''NOTE:''' As any "printing" template, it doesn't store any values anywhere, but merely prints them on the page.
 +
 
 +
'''Parameters:'''
 
* <code><nowiki>|authors=</nowiki></code> - a comma delimited list of authors.  
 
* <code><nowiki>|authors=</nowiki></code> - a comma delimited list of authors.  
 +
* <code><nowiki>|intro=</nowiki></code> - initial text that precedes the output, if at least some results exist.
 +
* <code><nowiki>|outro=</nowiki></code> - text that is appended to the output, if at least some results exist.
 +
* <code><nowiki>|default=</nowiki></code> - if, for any reason, the query returns no results, this will be printed instead.
  
 
</noinclude><includeonly><!--
 
</noinclude><includeonly><!--
-->{{#if: {{{authors|}}}<!--
+
-->{{#if: {{{authors|}}} <!--
  -->|{{#arraydefine:authorsArray |{{{authors|}}} }}<!--
+
  -->|{{{intro|}}}<!--
   -->{{#ifexpr: {{#arraysize:authorsArray}} < 4 |<!--
+
  --><!-- add the authors
   -->{{#arrayprint:authorsArray |;<nowiki> </nowiki>|@@@@|{{AuthorLastNameCommaFirstName|author=@@@@}}|print=pretty }}<!-- less than four authors
+
  -->{{#arraydefine:authorsArray |{{{authors|}}} }}<!--
   -->|{{AuthorLastNameCommaFirstName|author={{#arrayindex:authorsArray |0 }} }} ''et al.''<!-- more than three authors
+
  -->{{#arrayunique:authorsArray}}<!-- remove duplicates and empty values
 +
   -->{{#ifexpr: {{#arraysize:authorsArray}} < 4 <!--
 +
   -->|{{#arrayprint:authorsArray |;&#32;|@@@@|{{PrintAuthorLastNameCommaFirstName|author=@@@@}}|print=pretty }}<!-- less than four authors
 +
   -->|{{PrintAuthorLastNameCommaFirstName|author={{#arrayindex:authorsArray |0 }} }} ''et al''<!-- more than three authors
 
   -->}}<!--ifexpr
 
   -->}}<!--ifexpr
 +
  -->{{{outro|}}}<!--
 +
-->|{{{default|}}}<!--
 
-->}}<!--if
 
-->}}<!--if
 
--></includeonly>
 
--></includeonly>

Latest revision as of 11:54, 7 July 2017

This template is used to convert an array of author names like "Thomas Kuhn, Imre Lakatos, Larry Laudan" into a pretty list of "Kuhn, Thomas; Lakatos, Imre and Laudan, Larry". If there are more than three authors, the "Kuhn, Thomas et al." will be returned.

NOTE: As any "printing" template, it doesn't store any values anywhere, but merely prints them on the page.

Parameters:

  • |authors= - a comma delimited list of authors.
  • |intro= - initial text that precedes the output, if at least some results exist.
  • |outro= - text that is appended to the output, if at least some results exist.
  • |default= - if, for any reason, the query returns no results, this will be printed instead.