You are here:  » long product names


long product names

Submitted by rolli1 on Tue, 2012-05-08 08:47 in

Hi David,

one of my merchants delivers product names including size and color etc. like that:

Hi-Tec Sierra Sneaker Boots (Dark Choco/Stone) - Men's Boots - 7.5 M

The url looks then like that:

http://www.example.com/product/Hi-Tec-Sierra-Sneaker-Boots-Dark-ChocoStone-Mens-Boots-75-M.html

Is there a possibility to shorten this to e.g.

Hi-Tec Sierra Sneaker Boots
so that the url looks like that:

http://www.example.com/product/Hi-Tec-Sierra-Sneaker-Boots.html

Regards

Roland

Submitted by support on Tue, 2012-05-08 09:48

Hello Roland,

If it's manageable I would suggest using Product Mapping to translate the name - it's one of those things I'm afraid that is easy for a human to see where the name ends and additional info begins but almost impossible from a software point of view.

It would be straight forward to truncate all product names to a maximum of 4 words or something like that but probably less desirable than the longer URLs, but let me know if you want to give something like that a go...

Cheers,
David.
--
PriceTapestry.com

Submitted by rolli1 on Tue, 2012-05-08 12:46

Hi David,
I was looking into the datafeed, and found that under the option13 there was a productname given that does not include colour, size ...etc...
I will try to register and import the feed with option13.

Regards

Roland

Submitted by rolli1 on Tue, 2012-05-08 14:54

Hi again,

this step helped me to reduce the number of products from 330000 to 68000. Good move.

Regards

Roland

Submitted by babrees on Thu, 2012-05-10 06:47

Hi David

This is well timed!! I would like to truncate the title, but only on search results and featured, not product page. I have another script for something totally different that allows me to do this by putting [50] after the title in the html/template - would something like that be possible?

---------
Jill

Submitted by support on Thu, 2012-05-10 10:04

Hi Jill,

Sure - for search results, in html/searchresults.php look for each instance of:

<?php print $product["name"]; ?>

(within lines 16 and 18 in the distribution version)

...and REPLACE with:

<?php print tapestry_substr($product["name"],30); ?>

...for a 30 character or next space thereafter limit.

In html/featured.php, make exactly the same modification at line 9...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by babrees on Thu, 2012-05-10 11:37

PERFECT! Thanks David

---------
Jill

Submitted by ChrisNBC on Thu, 2016-12-01 11:34

Hi David,

I've used the above mod in a number of places on my site and it works perfectly. However, I'm struggling to truncate the product name in my products.php file. The code in product.php generating the name is :

    $banner["h2"] = translate("Price search results for")." <strong>".htmlspecialchars($q,ENT_QUOTES,$config_charset)."</strong>&nbsp;";

I wondered if you might be able to tell me how I could trim the output using the same criteria as the above mod to specify the number of characters or next space thereafter.

Thanks in advance.

Best regards
Chris

Submitted by support on Thu, 2016-12-01 11:49

Hi Chris,

Use the tapestry_substr() function, for example to truncate to 50 characters or next space, use:

    $banner["h2"] = translate("Price search results for")." <strong>".htmlspecialchars(tapestry_substr($q,50),ENT_QUOTES,$config_charset)."</strong>&nbsp;";

Cheers,
David.
--
PriceTapestry.com