Hello David
I'm posting this to the forum because I thought other people might have the same issue.
My products have "strengths" in them. For example:
"ProductA 12.5% solution". I need to keep the "12.5%" in the product name so that the PT comparison engine matches on the strength as well as the product in order to rank them and find the best buy. The issue is that if I modify the "includes" in order to allow special characters, such as "." and "%", while it will import the feed correctly, it does, as you suggested, mess up the search-engine-friendly urls and so clicking on the product in the search results list brings up nothing. Can you suggest any workarounds? (I've tried "percent" but can't think of a way round the decimal points!)
Thank you.
Alastair
I thought it might be useful if I clarified what I'd like to achieve in product names. I definitely need to be able to keep % signs and decimal points in product names e.g.
"ProductA 10.5%"
I would ideally like to be able to have hyphenated product names as well:
"hyphenated-ProductA 10.5%"
It would be excellent (but not essential) if I could have forward slashes:
"ProductA 10mg/5ml" though I could, if need be, replace with " per "
People might search using the decimal point, the percentage and the hyphen. Less likely to search using the forward slash.
I have added the special characters to the string of allowed ones in includes/admin but have the following issues:
While % and . are getting into the names fine, the urls for product with them in do not result in being able to access the product
It definitely doesn't like hyphens (I think tapestry nornalize is getting rid of them and doesn't like forward slashes.
Hi Alastair,
Can you check that everything works OK normally; without the search engine friendly URLs. Then it will mean we are only working on one thing - getting the search engine friendly URLs working with these characters....
To do this, can you change config.php as follows:
$config_useRewrite = FALSE;
Then check everything over and make sure it's working OK with "%", "." and "/"... We'll look at "-" separtely as you are correct - this is removed to make way for "-" being a replacement for SPACEs in the URLs...
Cheers,
David.
Hi Alastair,
It looks like this is being caused by the normalisation at the top of products.php, which is removing the extra characters you are now allowing into your site. This is done by the following code on line 4:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\."):"");
In that code, you will see the same list of permitted characters. What you want to do is match this exactly with the version in includes/admin.php where the product name is "normalised" during import. As "." is already allowed in this position, just add "%" by changing this as follows:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],"%:\."):"");
Cheers,
David.
David
Thank you. "ProductA 12.34%" now works fine! Next step is to figure out why "ProductB 10mg/ml" i.e. one with slashes in it is being dropped from the feed, even when / is specified in the "allow" in includes/admin.php. Thank you for persevering with this!
Alastair
Hi,
Where you need to specify "/" in the list of allowed characters, this probably needs to be "escaped" with a preceding back-slash (just like the full-stop character is) because it has special meaning within a regular expression, which is what that second parameter to tapestry_normalise() forms.
For example:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],"%:\.\/"):"");
(don't forget the corresponding change in includes/admin.php)
Cheers,
David.
Forward slash "ProductA 10mg/5ml" importing fine and being found by search fine, thank you. That just leaves the hyphen..
Many thanks
Hi Alastair,
To get hyphen working, we need to disable its use as a replacement character for spaces. To do this, look in the tapestry_hyphenate() function in includes/tapestry.php for the following code (line 20 in the distribution)...
$text = str_replace("-"," ",$text);
...and simply comment out (or delete) that line.
The "-" character will now have to be added to the list of allowed characters just as you have been doing before; so add it to the second parameter in the call to tapestry_normalise() in the import routine, and at the top of search.php and products.php...
That should do the trick...
Cheers,
David.
Thank you, I put the escape character before the hyphen and all seems fine!. Now I'm going to turn back on the Rewrite function.
Kind regards
Alastair
Just tested with "rewrite = true" and it seems to be fine with "%", ".", "-" but not "/"
Hi Alastair,
Can you post an examplified link that doesn't work properly so that I can compare it to the .htaccess rules and try to work out how it should be being interpreted...
Cheers,
David.
Hello David
The product is:
"ProductA 10mg/10ml"
The link seems to be http://blahblahblah/pt/product/ProductA+10mg%2F10ml.html
Thank you
Hi Alastair,
I couldn't find that product on your site when searching for "ProductA" - is it still listed? Could you perhaps email me a couple of links - one to the search results that show a product, and a corresponding product page that doesn't work....
I think we're getting close now; shouldn't be too hard to nail...!
Cheers,
David.
Hello Alastair,
Could you email me a link to one of the search engine friendly URLs that is being broken by the % (or the search results showing the product) and i'll take a look and consider what might be possible...
(reply to your reg code or forum registration email is the easiest way to get me)
Cheers,
David.