Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / General Questions / General Questions / Can you have a "short description" on the product info page AS WELL AS normal desc?

Can you have a "short description" on the product info page AS WELL AS normal desc?

16 Apr 2015, 3:42 PM
#1
sarahl avatar

sarahl

Zen Follower

Join Date:
May 2004
Location:
UK
Posts:
471
Plugin Contributions:
0

Post #1 by sarahl

Basically I would like to truncate the description - like a teaser with a read more link - and have the full description showing further down the page (I am currently using TPP (tabbed products pro)

Normally I would truncate from the SQL script and you can do it via advanced search - that just shows a short description/teaser

I can do it via PHP but not sure if there is a better way of doing it?

echo substr(stripslashes($products_description), 0, 100);

Thanks
Sarah

16 Apr 2015, 4:01 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #2 by mc12345678

SarahL:

Basically I would like to truncate the description - like a teaser with a read more link - and have the full description showing further down the page (I am currently using TPP (tabbed products pro)

Normally I would truncate from the SQL script and you can do it via advanced search - that just shows a short description/teaser

I can do it via PHP but not sure if there is a better way of doing it?

echo substr(stripslashes($products_description), 0, 100);

> 
> Thanks
> Sarah

Since you're not modifying the original text, anything that displays your "teaser" is just about as good as any other.  Some would use something like a clickable "read more" that would expand the text in place through javascript/css mods... Display the first part of the text wrapped in appropriate tags and your "button", followed by the remaining text (if there is any based on the length of the total text) that also is wrapped in tags too.

Would say it all depends on the effect you're after...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

16 Apr 2015, 4:04 PM
#3
sarahl avatar

sarahl

Zen Follower

Join Date:
May 2004
Location:
UK
Posts:
471
Plugin Contributions:
0

Post #3 by sarahl

Ok lovely thanks - I will see what clients prefers - I like the css drop down idea had forgotten that way!

Have to say I kind of like having this short description as a teaser for future releases - although first time I have thought of it in 11 years lol!

18 Apr 2015, 12:57 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,156
Plugin Contributions:
56

Post #4 by lat9

SarahL:

Basically I would like to truncate the description - like a teaser with a read more link - and have the full description showing further down the page (I am currently using TPP (tabbed products pro)

Normally I would truncate from the SQL script and you can do it via advanced search - that just shows a short description/teaser

I can do it via PHP but not sure if there is a better way of doing it?

echo substr(stripslashes($products_description), 0, 100);

> 
> Thanks
> Sarah
You could also use the built-in Zen Cart functions:

echo zen_trunc_string (zen_clean_html ($products_description), 100);

Adding the zen_clean_html also makes sure that you're not truncating the description in the middle of a <b> ... </b> type construct, which would result in improper HTML output.  

The zen_trunc_string function, by default, adds a ... at the end of the truncated string (if it's actually truncated).  You can add your own trailer (like [more]) by adding the 3rd parameter to the call:

echo zen_trunc_string (zen_clean_html ($products_description), 100, ' [more]');

20 Apr 2015, 8:09 AM
#5
sarahl avatar

sarahl

Zen Follower

Join Date:
May 2004
Location:
UK
Posts:
471
Plugin Contributions:
0

Post #5 by sarahl

oh wow - how fab! I didn't know that existed! that's a much better way fo doing it and my preferred way (like you say)

thank you very very much!