profwannabe
Programmer
I am trying to output bibliographic entries. The number of authors and their relative positions determines a variety of factors, such as "LastName, FirstName" versus "LastName, FirstName,", "FirstName LastName," or "and FirstName LastName". The same thing happens if the volume is edited and how many editors there are (e.g. ed. vs eds.).
To account for this I have a series of conditions within the loop that outputs the getAuthors query. The output is just fine, except that I get spaces resulting from the cfif statements. I have tried putting all the code on a single line (thinking that maybe by using separate lines in the code an extra space creeps in), but no luck. The code is below.
To account for this I have a series of conditions within the loop that outputs the getAuthors query. The output is just fine, except that I get spaces resulting from the cfif statements. I have tried putting all the code on a single line (thinking that maybe by using separate lines in the code an extra space creeps in), but no luck. The code is below.
Code:
<cfloop query="getAuthors">
<cfif LoopIndex GT 1>
<cfif loopIndex LT getAuthors.RecordCount>
,
<cfelseif loopIndex EQ getAuthors.RecordCount>
and
</cfif>
</cfif>
<cfif loopIndex IS 1>
#Trim(getAuthors.AuthorLastName)#, #Trim(getAuthors.AuthorFirstName)#<cfif Trim(getAuthors.AuthorDesignation) NEQ ""> #Trim(getAuthors.AuthorDesignation)#</cfif>
<cfelse>#Trim(getAuthors.AuthorFirstName)# #Trim(getAuthors.AuthorLastName)#<cfif Trim(getAuthors.AuthorDesignation) NEQ ""> #Trim(getAuthors.AuthorDesignation)#</cfif>
</cfif>
<cfif loopIndex EQ getAuthors.RecordCount>
<cfif getVolumeInfo.Edited IS "Yes">
<cfif getAuthors.RecordCount IS 1>
, ed.
<cfelse>
, eds.
</cfif>
<cfelse>
.
</cfif>
</cfif>
<cfset LoopIndex = IncrementValue(LoopIndex)>
</cfloop>