You are here:  » Allowing Characters in Product Name


Allowing Characters in Product Name

Submitted by jbperkins on Sat, 2008-12-06 20:27 in

Hi,

Is it possible to change the settings to allow text characters such as: "%", "+", "/", ".", etc. to be displayed in the Product Name and Description?

If so, how do I do this?

Thanks for any help.

Submitted by support on Sun, 2008-12-07 09:55

Hi,

The description field is currently cleansed by the following code on line 165 in includes/admin.php:

$record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],",'\'\.%!");

To permit additional characters, simply add to the list of allowed extra characters in the call to tapestry_normalise(). Of the characters in your post, "%" and "." should already be permitted, so to include + and /, change the above code as follows:

$record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],",'\'\.%!+/");

The product name is processed in a similar way on line 159:

$record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]]);

However, care must be taken if you are using search engine friendly URLs, as by default almost everything is stripped in order to make everything URL safe. Further, any modifications to the characters allowed in the product name must be mirrored by the cleansing of the query parameters ($_GET["q"]) at the top of search.php and products.php (line 4 in both files). So, to permit the % character, change the above line in includes/admin.php to:

$record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]],"%");

(note that this call to tapestry_normalise() does not already have an extra characters parameter)

And then in search.php and products.php, add the same character to the permitted characters parameter (which does exist in these cases); for example:

$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\.%"):"");

Cheers,
David.

Submitted by jbperkins on Mon, 2008-12-22 06:40

Hi David,

Thanks again for all your help.

Could you give me an example of how to add multiple characters in search.php and products.php?

For example, if I was adding "%" and "/" how would I change the code in those two files? How are multiple characters supposed to be listed?

I have tried the following method but got some errors...

$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\.%/"):"");

Thanks.

Submitted by support on Mon, 2008-12-22 09:08

Hi,

That's almost there, the only problem is that "/" when in a regular expression needs to be escaped, so it needs to appear as "\/", for example:

$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\.%\/"):"");

That should be all it is!

Cheers,
David.