CFLib.org – Common Function Library Project

LeftDotDot(str[, l])

Last updated May 10, 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>

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson