Submitted by goldengirl on Sat, 2010-05-15 19:09 in Price Tapestry
Hi David
Is there anyway to put a limit on the number of characters in a URL. The reason I ask is sometimes merchants use very long product names which makes the URL for that product very long.
Provided that it shouldn't affect uniqueness, it's straight forward to shorten the normalised version of the product names that is used to generate the URL. I would recommend breaking it on the nearest space character to your chosen maximum length, say 30 characters in this example. To do this, look for the following code beginning at line 271 of includes/admin.php
/* create normalised version of product name for use in URLs */
$normalisedName = tapestry_normalise($importRecord["name"]);
...and REPLACE that with:
/* create normalised version of product name for use in URLs */
$normalisedName = tapestry_normalise($importRecord["name"]);
$breakLimit = 30;
if (strlen($normalisedName) > $breakLimit)
{
$breakOffset = strpos($normalisedName," ",$breakLimit);
if ($breakOffset !== false)
{
$normalisedName = substr($normalisedName,0,$breakOffset);
}
}
The shortened names will take effect after the next import..
Hi there,
Provided that it shouldn't affect uniqueness, it's straight forward to shorten the normalised version of the product names that is used to generate the URL. I would recommend breaking it on the nearest space character to your chosen maximum length, say 30 characters in this example. To do this, look for the following code beginning at line 271 of includes/admin.php
/* create normalised version of product name for use in URLs */
$normalisedName = tapestry_normalise($importRecord["name"]);
...and REPLACE that with:
/* create normalised version of product name for use in URLs */
$normalisedName = tapestry_normalise($importRecord["name"]);
$breakLimit = 30;
if (strlen($normalisedName) > $breakLimit)
{
$breakOffset = strpos($normalisedName," ",$breakLimit);
if ($breakOffset !== false)
{
$normalisedName = substr($normalisedName,0,$breakOffset);
}
}
The shortened names will take effect after the next import..
Hope this helps!
Cheers,
David.