CFLib.org – Common Function Library Project

LeftDotDot(str[, l])

Last updated May 9, 2009

author

Peter Coppinger

Version: 0 | Requires: CF5 | Library: StrLib

Description:
leftDotDot turns "This is a nice day" into "This is a nic..". You can specify the clipping length. This is very handy when you have a limited layout or just want to give a preview. Or if you just want to ensure that some ridiculously long name doesn't mess things up. We use it extensively in Teamwork Project Manager.

Return Values:
Returns a string

Example:

<cfoutput>#HTMLEditFormat( LeftDotDot( productDescription, 50 ) )#</cfoutput>

Parameters:

Name Description Required
str String to use Yes
l length to use No

Full UDF Source:

<!---
 leftDotDot turns &quot;This is a nice day&quot; into &quot;This is a nic..&quot;
 
 @param str 	 String to use (Required)
 @param l 	 length to use (Optional)
 @return Returns a string 
 @author Peter Coppinger (peter@digital-crew.com) 
 @version 0, May 9, 2009 
--->
<cffunction name="leftDotDot" output="no" returntype="string">
	<cfargument name="str" type="string" required="yes">
	<cfargument name="l" type="numeric" required="no" default="80">
	
	<cfset var result = str>
	
	<cfif Len( str ) GT l>
		<cfset result = Left( Trim(str), l-2 ) & "...">
	</cfif>
	
	<cfreturn result>
	
</cffunction>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson