You are here:  » Truncating Names on Featured Products Page


Truncating Names on Featured Products Page

Submitted by ChrisNBC on Thu, 2017-07-06 15:33 in

Hi David,

Hope all is going well.

I’m trying to truncate the product names used on my featured product page. I’ve truncated the names elsewhere on the site without issue but I’m struggling with the ones on the featured page…

I changed the code from:

<?php if ($product["image_url"]): ?>
<a href='<?php print $product["productHREF"]; ?>'><img src='<?php print htmlspecialchars($product["image_url"],ENT_QUOTES,$config_charset); ?>' alt='<?php print htmlspecialchars($product["name"],ENT_QUOTES,$config_charset); ?>' class="item_image" /></a>
<?php endif; ?>

to:

<?php if ($product["image_url"]): ?>
<a href='<?php print $product["productHREF"]; ?>'><img src='<?php print htmlspecialchars($product["image_url"],ENT_QUOTES,$config_charset); ?>' alt='<?php print tapestry_substr($product["name"],25); ?>' class="item_image" /></a>

I wondered if you might be able to suggest what the code should be.

Thanks in advance.

Best regards
Chris

Submitted by support on Fri, 2017-07-07 07:25

Hello Chris,

The above mod would only change the product name in the alt tag of the image. I know you're using a custom template but if you check elsewhere in your Featured Products HTML module you should find another instance where $product["name"] is output - search either for that specifically or alternatively:

print $product["name"]

...and if located, REPLACE with:

print tapestry_substr($product["name"],25);

If you're not sure of course email me the file to me and I'll check it out further for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Mon, 2017-07-10 16:15

Hi David,

Thanks for your message above. Can't believe I missed it was the alt tag code I was changing!...I didn't get any matches in the code against the above but instead searched for "name" and found where the title was being set and have managed to change it and all is now working perfectly...

Thanks again for your help.

Best regards
Chris