You are here:  » Limiting the length of the displayed product description.


Limiting the length of the displayed product description.

Submitted by shabbysheep on Fri, 2017-01-27 00:44 in

Hi all, I would like to limit the length of product list descriptions so that my pages become more consistent in length. An older post (2009) describes how to do acheive this (http://www.pricetapestry.com/node/3156), but the PT code has changed somewhat since then. What would be up-to-date code to limit descriptions to a given amount of characters? (and also give clean breaks after the last word).

Thanks!

Submitted by support on Fri, 2017-01-27 08:17

Hi,

You can now use the tapestry_substr() function which will break the description on the next space following the length specified, so if you edit html/product.php and look for the following code at line 44:

      <p><?php print $product_main["description"]; ?></p>

...and REPLACE with:

      <p><?php print tapestry_substr($product_main["description"],200,"..."); ?></p>

(the third parameter is an optional postfix string that the function will add if the string is truncated)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com