Been using this forever.
 
<!--- 
Author: Bobby Hartsfield | [EMAIL PROTECTED]
File: trimtext.cfm
Description: This tag will take the text passed to it and create a "teaser"
             Meaning, it will trim the text back and add a trailing ... to
the end 
                         Making for a good teaser news article with a "read
more" link.
                         
                         Give the tag the text to trim and the number of
characters to trim it at
                         it will trim to that specified number and work its
way "BACK" to the first 
                         space character and add ...
                         
--->
<cfparam name="attributes.paragraph" default="">
<cfset paragraph=attributes.paragraph>

<cfparam name="attributes.trimat" default="12">
<cfset trimat=attributes.trimat>

<cfoutput>
<!--- if the paragraph to be trimmed is longer than the number specified in
the "Trimat" attribute --->
        <cfif len(paragraph) gt trimat>
                
                <!--- trim it to the legth specified through the trimat
attribute --->  
                <cfset CutParagraph = trim(left(paragraph, trimat))>

        
                <!--- now trim from the end to the next space as to not cut
any words in half--->                                               
                <cfset FinalParagraph = listdeleteat(CutParagraph,
listlen(Cutparagraph, " "), " ")>
                #finalparagraph#...
        <cfelse>
                <!--- else if the paragraph is equal to or less than the
trimat specifications display it without any editing ---> 
                #paragraph#
        </cfif>
</cfoutput>



-----Original Message-----
From: Nate Willard [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 24, 2008 7:23 PM
To: CF-Talk
Subject: Re: Perhaps a little over complicated - Dissecting a String

These are all good steps in the right direction however, I haven't found
anything that ties all this logic together. 

Logic
if first sentence is between 200-250 characters show that setence
if no sentence, show first 250 characters +...
if first sentence is less than 250 sentences, get as many sentences as
possible before hitting 250 characters and output.

Has anyone built something like this?

Thanks

Steve Bryant <[EMAIL PROTECTED]> wrote: I think you want:
#Left(ListFirst(string,"."),100)#.
(untested)

> Instead of returning say just 100 characters. Is there a way to return 
> the first sentence only if its under 100 characters, and if not then 
> 100 characters resulting in a cut off string. 





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:301984
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to