Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display a partial section

Status
Not open for further replies.

brantGuy

Programmer
Feb 12, 2007
59
CA
Im currently using
Code:
#Left(qGetArticles1.event, '50')#

to display a teaser for an event or an article...it just displays the first 50 characters...the problem with this is that it indiscriminantly cuts a word off anywhere...how can i ask it to go to 50 characters then cut the display off at the next blank space...

Appriciate any help...

Thanks
 
<cfset myText = 'to display a teaser for an event or an article...it just displays the first 50 characters...the problem with this is tha'>


<cfif Left(myText, 50) IS ' '>
<cfset teaser = Left(myText, 50)>
<cfelse>
<cfset nextPos = Find(" ", myText, 50)>
<cfset teaser = Left(myText, nextPos)>
</cfif>
<p>
<cfoutput>#teaser#</cfoutput>
<p>

hope it helps...

 
my bad, i forgot to test, and of course my initial stab at it was wrong

here ya go...

#Left(qGetArticles1.event
, REFind('[[:space:]]', qGetArticles1.event , 50))#

r937.com | rudy.ca
 
I use my old code for this still

listDeleteAt(left(qGetArticles1.event,50),listLen(qGetArticles1.event," ")," ")

But I kinda like Left(qGetArticles1.event,REFind('[[:space:]]',qGetArticles1.event,50)) now.

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
can I use a similar technique to break a long article in to pages...

like display first 1500 characters, then look for paragraph break

at the paragraph break, insert link to new page.
 
r937 are you askin how do I do it or how is it done..

If the former, im not doing it currently, and if the latter, I have no clue..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top