• Toll-free  888-665-8637
  • International  +1 717-220-0012
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

sternyy
#1 Posted : Thursday, January 8, 2009 4:49:51 PM(UTC)
sternyy

Rank: Member

Joined: 1/10/2005(UTC)
Posts: 714

Thanks: 14 times
Was thanked: 1 time(s) in 1 post(s)
I have successfully truncated my short description to X amount and adding a "..." at the end. The problem is that when you truncate to a number of characters, it could cut off a word in the middle. Anyone have any suggestions on how to truncate the short description by a number of characters WITHOUT cutting off a word? What would be cool is if i could truncate by the first or second period. That way i can get atleast 2 sentences in. Either way, by periods or words is fine. This is what currently works below but it cuts of words:

Code:

Dim shortdesc as string
shortdesc = p.ShortDescript[b][/b][b][/b]ion
dim trun as string



trun = left(shortdesc, 200) & "..."
litDes.Text = "<div class=""recordshortdescript[b][/b][b][/b]ion"">" & trun & "</div>"


bvcoder
#2 Posted : Thursday, January 8, 2009 5:05:28 PM(UTC)
bvcoder

Rank: Member

Joined: 8/1/2007(UTC)
Posts: 310

For period..., do this:
1. use Split string function to split your description based on a period. That will get you an string array of sentences that were delimited by a period.
2. Based on your requirement, join the the array items and display that to the user. If you need to show the first 3 sentences, then you will need to concatenate the first 3 items in the array.

If you want to do it based on words, do the exact same thing but split based on a space character. Again, depending on your requirements, show the number of words by appending them.

Either ways you will want to create a function that returns you the string you want to display. Also, take care of checking if an array item is not null before trying to append it, etc.
Thanks,
Satya
support @ bayquel.net
Work: +1 803 883 3226
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

©2024 Develisys. All rights reserved.
  • Toll-free  888-665-8637
  • International  +1 717-220-0012