How do I import utf-8 datafeeds into the database so that they display correct punctuation rather than the utf-8 encoded version. I am now manually importing data but am running the imports as a daily CRON job.
As an example, I need to display '&' in datafeeds but this is coming through as 'amp' in the descriptions and names.
My sites are all iso-8859-1 content equivalent.
Many thanks for a superb script - best I have ever used by a long shot.
Hi David,
I have a problem that once there is & sign in the product name it can't be displayed as the name is cut by the _GET in products.php.
Do you have any suggestion for workaround to this problem?
Regards,
Danny
Hello Danny,
As search.php isn't expecting these characters to be included in the product name, if you are using search engine friendly URLs ($config_useRewrite = TRUE; in config.php) it would be necessary to add urlencode() to the product name. To do this, look for the following code on line 166:
$searchresults["products"][$k]["productHREF"] = "product/".tapestry_hyphenate($product["name"]).".html";
...and REPLACE that with:
$searchresults["products"][$k]["productHREF"] = "product/".urlencode(tapestry_hyphenate($product["name"])).".html";
Cheers,
David.
Thanks David,
But the problem is not with the search.php it is with the products.php as it handle only the name part until the & and therefore cannot find the product which can be seen in the search results with encoded url.
Danny
Hi,
This sounds like an HTML entities problem rather than a character set issue, as the HTML entity for the & character is:
&
...however & and ; are stripped during import as part of the data sanitisation / normalisation. The easiest thing to do to avoid having to create lots of filters is perhaps to permit those characters for the description field - it is the product name where they would cause problems. To do this, look for the following code on line 165 of includes/admin.php:
$record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],",'\'\.%!");
...and replace this with:
$record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],",'\'\.%!&;");
(and then re-import for the changes to take effect)
Cheers,
David.