Monday, March 26, 2012

Item Description in Shorthand

Hi,
If you browse to Amazon and drill down through categories until a pagedlisting appears, you will see in each item of the listing that thedescription rendered as Book Description, is a cutdown version of thefull description, with a ... and "Read More" hyperlink. How isthis achieved programatically? I dont know if thre is an efficient wayin SQL Server to do this, or whether it would be easier to have aShortHand field and a Description field, both of which are teh fulldescription when shown in the Details page, but the ShortHand is thefield rendered in listings. This seems like a simplistic solutionand I am thinking there may be programmatic means of doing the same -has anybody got any experience in this area?
Thanks!
jr.
Well, its just a substring from the complete description. In SQL you could simply return this from your stored procedure - lets say the first 100 chars with SubString and append the '...' to it. The same can be done from code. Both uses the SubString function.|||Hi Sonu,
I have used this as my technique, but Amazon is neat because they havewhole words at the end. Just using 1-100 means I could getincomplete words back, which doesnt look as professional. I agreethis is a simple solution though.
jr.
|||Does it matter if they have whole words at the end or not? In either case, you would append the "...", right?
Doesnt that look good?
"This is some test and I want to ment..."|||Hi,
Yeh it does to me - I think it looks better and cleaner. I didthe first job of cutting down the text in the DB, and then used C#before rendering to substring to the last space, which works nicely.
Thanks,
jr.

No comments:

Post a Comment