Byline(names [, editors] [, extrasMode])
Last updated October 10, 2002
Version: 1 | Requires: ColdFusion 5 | Library: StrLib
Description:
Generate a byline from a comma-delimited list of one or more names, in the format 'by X[, Y & Z]'. Also extensible to perform extra functions: currently included is the ability to generate links to iMDB for each name.
Return Values:
Returns a string.
Example:
Naked Lunch, #Byline("William S. Burroughs")#<br />
Boring Book, #Byline("F.P. Morden,B.J. Smith,A.B.Q. Forsythe", TRUE)#<br />
Santa Sangre, directed #Byline("Alejandro Jodorowsky", FALSE, "imdb")#<br />
</cfoutput>
Parameters:
| Name | Description | Required |
|---|---|---|
| names | List of Names. | Yes |
| editors | Boolean signifying that the list is a list of editors. Defaults to false. | No |
| extrasMode | String signifying extrasMode to use. Currently "IMDB" is support. Defaults to "none". | No |
Full UDF Source:
<cfscript>
/**
* Generates a byline from a list of names.
*
* @param names List of Names. (Required)
* @param editors Boolean signifying that the list is a list of editors. Defaults to false. (Optional)
* @param extrasMode String signifying extrasMode to use. Currently "IMDB" is support. Defaults to "none". (Optional)
* @return Returns a string.
* @author Gyrus (gyrus@norlonto.net)
* @version 1, October 10, 2002
*/
function Byline(names) {
// Initialise
var i = 0;
var name = "";
var bylineString = "";
var edited = FALSE;
var extrasMode = "none";
if (ArrayLen(Arguments) GT 1) {
edited = Arguments[2];
}
if (ArrayLen(Arguments) GT 2) {
extrasMode = Arguments[3];
}
// Loop through names
if (ListLen(names)) {
for (i=1; i LTE ListLen(names); i=i+1) {
name = ListGetAt(names, i);
// Edited?
if (edited) {
name = "#name# (ed.)";
}
// Perform extras
switch (extrasMode) {
case "imdb": {
name = "<a href=""http://uk.imdb.com/Name?#Replace(name,' ','+','ALL')#"" title=""check for information on this person on the Internet Movie Database"">#name#</a>";
break;
}
}
if (i EQ 1) {
bylineString = "by #name#";
} else if (i EQ ListLen(names)) {
bylineString = "#bylineString# & #name#";
} else {
bylineString = "#bylineString#, #name#";
}
}
}
return bylineString;
}
</cfscript>
Search CFLib.org
Latest Additions
Ryan Thompson-Jewell added
ListSplit
2 day(s) ago
Nathan Dintenfass added
RowsToColumns
2 day(s) ago
Barney Boisvert added
indentXml
3 day(s) ago
Barney Boisvert added
REReplaceCallbac...
3 day(s) ago
Top Rated
FolderSize
Rated 5.0, 7 time(s)
UniqueValueList
Rated 5.0, 5 time(s)
QuickSort
Rated 5.0, 3 time(s)
ListDeleteDuplic...
Rated 5.0, 3 time(s)