Home: Support: Reference Guide: Display Tags: <dpAuthor>

<dpAuthor>

D E F I N I T I O N:

The author of the story currently being built or queried. By default <dpAuthor> will always return all of the authors of the story.

<dpAuthor
  format="standard|initials|fmlast|firstlast|lastfirst|first|middle|last"
  number="#|all"
  return="value|count"
  default="default text"
  style="lower|upper|title|spaced|roman|decimal|identifier|
         noHtml|noHtmlStyle|scriptEncode|uriEncode"
  link="on|off|email|homepage"
  start="#p|#s|#w|#c|begin|end|resume"
  stop="#p|#s|#w|#c|begin|end|resume"
  length="#p|#s|#w|#c|begin|end"
>


A T T R I B U T E S:

format="standard|initials|fmlast|firstlast|lastfirst|first|last|middle"

Using "Kay Anne Sather" as an example:

<dpAuthor format="standard"> - Kay Anne Sather
<dpAuthor format="initials"> - KAS
<dpAuthor format="fmlast"> - K A Sather
<dpAuthor format="firstlast"> - Kay Sather
<dpAuthor format="lastfirst"> - Sather, Kay
<dpAuthor format="first"> - Kay
<dpAuthor format="middle"> - Anne
<dpAuthor format="last"> - Sather

number="#|all"

If their are multiple authors of a story, you may optionally reference the individual authors using the number attribute. For example number="1" would return the first author and number="2" would return the second author.

number="all" is the default and will always return all the authors of a story, be it one or many.

return="value|count"

By default all author(s) names are returned (return="value"). You may optionally return the count which tells you how many authors an individual story has, and then loop through the authors one by one using the number attribute.

For example:

<dpIf <dpAuthor return="count"> = 1>
     {do the regular author layout}
<dpElseIf <dpAuthor return="count"> gt 1>
     {do the multi author layout and loop through the authors}
</dpIf>

The following expands on this concept and creates a link to the author's archive page. If there are multiple authors, it will create a link to each author's individual archive page by looping through them.

<dpIf <dpAuthor return="count"> = 1>
   <dpAuthorCredit> <a href="../authors/<dpAuthorID>.html"><dpAuthor></a>
<dpElseIf <dpAuthor return="count"> gt 1>
   <dpAuthorCredit>
   <dpLoop var="i" from="1" to="<dpAuthor return="count">">
      <a href="../authors/<dpAuthorID number="<dpVar i>">.html">
      <dpAuthor number="<dpVar i>"></a>
      <dpIf <dpVar i> lt <dpAuthor return="count">>
        ,
      </dpIf>
    </dpLoop>
</dpIf>

The idea is to loop through however many authors you have (from="1" to="<dpAuthor return="count">"), and then process each one individually, using the number attribute and the loop variable (<dpVar i>).

An additional test is performed to see if it is the last author or not. If it isn't a comma is displayed.


Please refer to the common attributes page for the common attribute descriptions.


E X A M P L E S:

<dpAuthor>
Jeff Smith 
<dpAuthor link="email">
Jeff Smith 
<dpAuthor format="initials">
JS 
<dpIf <dpAuthor>>
  <i><dpAuthorCredit> <dpAuthor></i>
</dpIf>
By Jeff Smith  


Customizing Author Formatting [1/2]

<dpAuthor number="all"> is the default value for authors and will always display multiple authors in the following format:

Humpty Dumpty, Robert Crumb and Dr. Seuss

If you decide you want to customize this, you can do so by looping through the authors as follows.


T A G   C O D E:

<dpLoop var="i" from="1" to="<dpAuthor return="count">">
  <dpAuthor number="<dpVar i>">
  <dpIf <dpVar i> = <dpMath <dpAuthor return="count">-1>>
    &
  <dpElseIf <dpVar i> != <dpAuthor return="count">>
    ,
  </dpIf>
</dpLoop>


E F F E C T:

Phil Campbell, Josh Feit, Trisha Ready & Jennifer Vogel


A D D I T I O N A L   I N F O R M A T I O N:

This code always displays an author. It then tests to see if it is the one before last in a multiple author scenario. If it is, it displays an "&". If it isn't, it tests to make sure it isn't the last author and displays a comma.


Customizing Author Formatting [2/2]

A more common customization would be to add a link to an author archive page. This can be achieved with the same logic as the previous example, with the addition of a link around the author's name.


T A G   C O D E:

<dpLoop var="i" from="1" to="<dpAuthor return="count">">
  <a href="../archives/<dpAuthorID number="<dpVar i>">.html"><dpAuthor number="<dpVar i>"></a>
  <dpIf <dpVar i> = <dpMath <dpAuthor return="count">-1>>
    &
  <dpElseIf <dpVar i> != <dpAuthor return="count">>
    ,
  </dpIf>
</dpLoop>


E F F E C T:

Phil Campbell, Josh Feit, Trisha Ready Jennifer Vogel


Modifying Multiple Author, Artist and UDF Output


T A G   C O D E:


E F F E C T:


Testing for Multiple Authors

By default <dpAuthor> and <dpAuthorID> will always return all authors if there are multiple author. For example:

<dpAuthor>

Robert Crumb and Neil Gaiman.

If you want to have a special layout for single authors and another layout for multiple authors, you can test the author count in a condition to achieve this.


T A G   C O D E:

<dpIf <dpAuthor return="count"> = 1>
    # single author layout goes here
<dpElse>
   # multiple author layout goes here
</dpIf>


E F F E C T:


A D D I T I O N A L   I N F O R M A T I O N:

The following is an example of how you might link to individual author archive pages:

<dpIf <dpAuthor return="count"> = 1>
    <dpAuthorCredit>
    <a href="../authors/<dpAuthorID>.html"><dpAuthor></a>
<dpElseIf <dpAuthor return="count"> gt 1>
    <dpAuthorCredit>
    <dpLoop var="i" from="1" to="<dpAuthor return="count">">
        <a href="../authors/<dpAuthorID number="<dpVar i>">.html"><dpAuthor number="<dpVar i>"></a>
        <dpIf <dpVar i> lt <dpAuthor return="count">>
            ,
        </dpIf>
    </dpLoop>
</dpIf>


Exploring the Author Format Attribute

The following are examples of how to use the format attribute in <dpAuthor>.


T A G   C O D E:

<dpAuthor> returns: Harry Dean Stanton
<dpAuthor format="first"> would return: Harry
<dpAuthor format="middle"> would return: Dean
<dpAuthor format="last"> would return: Stanton
<dpAuthor format="last" style="upper"> would return: STANTON


E F F E C T:


Testing for Author E-mail

You can have your author names linked to their e-mail addresses by using <dpAuthor link="email">, but what if an author doesn't have an e-mail address in the database?

With the following code, you can test to see if an e-mail address exists and, if not, link to a generic e-mail account.

Note that we start by testing to see if an author exists.


T A G   C O D E:

<dpIf <dpAuthor>>
  <dpIf <dpAuthor link="email">!=<dpAuthor>>
    <dpAuthor link="email">
  <dpElse>
    <a href="mailto:letters@yourpub.com"><dpAuthor></a>
  </dpIf>
</dpIf>


E F F E C T:


Home: Support: Reference Guide: Display Tags: <dpAuthor>
Questions? Comments?
Please write support@desert.net.