You are here:  » Allowing / character in description

Support Forum



Allowing / character in description

Submitted by Mark on Thu, 2009-01-22 18:25 in

I should know this but I just can't find the cose - how do I allow a / character in description?

Submitted by support on Thu, 2009-01-22 19:15

Hi Mark,

Sure - it's line 165 of includes/admin.php:

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

...REPLACE this with:

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

(in other words, just add / to the list of allowed characters, but it must be preceded by the escape "\" character)

Cheers,
David.

Submitted by stevencrocker on Fri, 2009-04-03 01:15

I also have an issue with needing characters to appear in description.

How would I add the following "(" ")" "-"

I have tried to add them as suggested here and I get errors with each of them.

Thanks.

Submitted by support on Fri, 2009-04-03 08:44

Hi Steven,

To allow those characters replace the line referred to above with:

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

Alternatively, if you're happy with the quality of the description fields in the feeds you are using, you can comment out or delete that line to import the descriptin "as-is".

Cheers,
David.

Submitted by stevencrocker on Sat, 2009-04-04 05:55

David,

Thanks for the quick reply. I have decided to comment out the description and see how that works out.

On a related note how would I go about adding the following to the product name:

"/" "(" ")" "-" I currently have the "." added and it is working. I am just not sure about how to add the additional characters.

Here is what I have from includes/admin.php

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

I am not especially worried about the way search engines will see these pages as there are really only a handful of products that this will be necessary with.

Thanks,

Steven

Submitted by support on Sat, 2009-04-04 08:38

Hi Steven,

Try something like this:

$record[$admin_importFeed["field_name"]] = tapestry_normalise($record[$admin_importFeed["field_name"]],"\.()\/\-");

However, you also need to add the same characters to the normalise call at the top of products.php, on line 4 look for the following code:

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

...and REPLACE this with:

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

Cheers,
David.

Submitted by stevencrocker on Sat, 2009-04-04 13:48

Thanks David.

Submitted by stevencrocker on Sat, 2009-04-04 15:41

David,

Upon further testing I am running into issues with the "/" in regards to the link that is generated for the product. It seems to work sometimes but not always.

I am thinking I could probably do without it all together if I could replace the removed characters from the normalise process with a space? This way I would not have words running together.

example: 200mg/5ml would become 200mg 5ml instead of 200mg5ml

Thanks.

Submitted by support on Mon, 2009-04-06 07:36

Hi Steven,

For a single line mod, you could make the tapestry_normalise() function replace dangerous characters with a space as follows. Look for the following code on line 27 of includes/tapestry.php

$text = preg_replace('/[^A-Za-z0-9'.$allow.' ]/e','',$text);

...and REPLACE this with:

$text = preg_replace('/[^A-Za-z0-9'.$allow.' ]/e',' ',$text);

An alternative would be to change the filter order so that user filters are applied before normalisation; this can be done quite easily in includes/admin.php, if you look for the block of code beginning with the comment:

/* apply user filters */

(11 lines of code - i.e. until the next comment) and move that block ABOVE the following comment on line 158:

/* apply standard filters */

You would then be able use Search and Replace to replace any specific characters with a SPACE, before any other dangerous characters are removed as normal.

Cheers,
David.

Submitted by stevencrocker on Mon, 2009-04-06 14:43

David,

Thanks for the reply. However, the mod above to line 27 does not appear to have any impact at all. The product name is still the same with the character stripped and no space inserted.

Is there perhaps something else that needs to be changed as well?

I prefer to make this change during normalisation rather than change the filter order if possible.

Thanks so much for all your help.

Steven

Submitted by support on Mon, 2009-04-06 19:35

Hi Steven,

Could you email me your includes/tapestry.php and includes/admin.php and i'll check it out for you...

Cheers,
David.