You are here:  » Limit description text with a link to merchant site


Limit description text with a link to merchant site

Submitted by jamie on Wed, 2016-08-31 20:02 in

Hi David,

Is there a way to limit the description on product pages to 300 words, but if the description goes past 300 words there is a link saying "More..." where if the user clicks it, they will be directed to the buy URL in the merchants site (so via jump.php)?

Thanks very much,
Jamie

Submitted by support on Thu, 2016-09-01 07:49

Hello Jamie,

Sure - in html/product.php look for the following code at line 44:

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

...and REPLACE with:

    <?php if ($product_main["description"]): ?>
      <p>
      <?php
       $limit = 1000;
       if (strlen($product_main["description"]) > $limit)
       {
         print tapestry_substr($product_main["description"],$limit,"<a href='".tapestry_buyURL($product_main)."'>More...</a>");
       }
       else
       {
         print $product_main["description"];
       }
      ?>
      </p>
    <?php endif; ?>

Adjust $limit as required. The tapestry_substr() function is a "tidy" substring method that splits at the next space following the length, with the final parameter being text to append if truncated, in this case the "More..." link as the Buy URL.

Cheers,
David.
--
PriceTapestry.com

Submitted by jamie on Thu, 2016-09-01 09:08

Thank you very much for the excellent support (and product) you give David - very much appreciated