In one of my feeds I have codes like (for example):
& # 2 3 2 ; (without spaces)
On the site it's only "232", and not the letter which it should be..
Normaly I would convert decode/encode (with filters) it to UTF-8, but that doesn't work.. I see no difference on my site (and yeah, I know how these filters work and I know that I have to import the feed again before it works).
Thanks in advance!
Hmm, they are mostly in the category field.. I will just have to map these categorys by hand?
Hi,
You should be OK permitting the codes in the category field. Again in includes/admin.php on line 170 this time look for the following code:
$record[$admin_importFeed["field_category"]] = tapestry_normalise($record[$admin_importFeed["field_category"]]);
...and change to:
$record[$admin_importFeed["field_category"]] = tapestry_normalise($record[$admin_importFeed["field_category"]],"&#;");
Cheers,
David.
I have modified these two lines, and yes, PT views the category-names exactly how it should be.. But the URL's now point to a 404, he can't find any products with these characters?
Hi,
I'm afraid this is what I was worried about - and is why these characters are stripped in the first place. Ultimately, it is a trade-off between having excellent search engine friendly URLs, Vs having perfect "as per the feed" naming.
However, the script does use urlencode so you may be able to make it work using the following modification in search.php. Line 4 performs the same normalisation on the query, which is query you are getting the 404. It is currently as follows:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\."):"");
Change this line to permit the new characters:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\.&#;"):"");
If this doesn't help; i'm afraid the best advice would be to roll back these changes, and perhaps contact the merchant and ask them not to use HTML entities in their product feeds, as it should really be down the consumer of the feed to implement entities where required.
Cheers,
David.
Well, it didn't work so I'll map these categories by hand.. Little more work, but it shall do the trick.
I have also another question: How can I let a "/" sign be imported in the Brands field?
That doesn't work (from includes/admin.php), it gives an error when I import the feed.
How can I fix this?
Hi,
Because of the way URLs work i'm afraid a forward slash is even more dangerous! However, you can experiment with similar modifications to the above, although it sounds like you may already have done so. What error do you get when importing the feed? The mods would be required on line 175 of includes/admin.php
$record[$admin_importFeed["field_brand"]] = tapestry_normalise($record[$admin_importFeed["field_brand"]]);
...as follows:
$record[$admin_importFeed["field_brand"]] = tapestry_normalise($record[$admin_importFeed["field_brand"]],"/");
Similarly, and as above, you would need to allow "/" on the query. In search.php, line 4:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\."):"");
..change to:
$q = (isset($_GET["q"])?tapestry_normalise($_GET["q"],":\./"):"");
(assuming that you've removed the mods described above).
You will need to test this carefully - as search engine friendly URLs are not urlencoded and rely on there being no dangerous characters. To be honest, I would not recommend permitting / in the any field.
Hope this helps,
Cheers,
David.
Well, I shall exlain why I need a "/" in my brands-field.
I have a feed with the following style in the brands-field:
"Egypte/Hurghada/Hurghada" (but no quotes)
I want to allow the "/" so I can use the "splitbefore" as descriped here.
I only need the "Egypte" part.
The error I get it is:
Warning: preg_replace(): Unknown modifier ']' in /home/***/domains/***/public_html/zonvakantie/includes/tapestry.php on line 27
This error is there A LOT, I guess 1 error for each product. I haven't modified tapestry.php ever, so that is the basic version.
Hi,
This should work ok. It's my mistake in the modification above - the / needs to be escaped with a preceeding "\". I've just tested this on my dev server. In includes/admin.php on line 175 change from the previous modification to the following:
$record[$admin_importFeed["field_brand"]] = tapestry_normalise($record[$admin_importFeed["field_brand"]],"\/");
Sorry about that - it should then work as you're expecting...
Cheers,
David.
Thnx david, you are really my hero!
It all works fine right now :-)
Right now I'm trying to allow a "-" in the Brands field, but it seems I can't get it working..
I tried "-" and "\-", but it doesn't import the "-".. The reason for this, is that I have to explode it, just like the "a/b/c/d" where I was talking about in another topic, but this feed looks like "a - b - c - d"..
Thanks in advance :-)
Hi,
The reason for this is that the tapestry_normalise() function deals with "-" separately to other characters. This is because "-" is used in the URL in place of the space character to generate search engine friendly URLs.
If you want to allow "-" in the brand, and you are confident that there are no other dangerous characters I would actually suggest removing the normalise function. In includes/admin.php, the brand field is normalised in the following code (starting at line 173):
if ($admin_importFeed["field_brand"])
{
$record[$admin_importFeed["field_brand"]] = tapestry_normalise($record[$admin_importFeed["field_brand"]]);
}
To remove it altogether, just comment out the call...
if ($admin_importFeed["field_brand"])
{
// $record[$admin_importFeed["field_brand"]] = tapestry_normalise($record[$admin_importFeed["field_brand"]]);
}
Cheers,
David.
Hi,
These codes are HTML entities, and the reason they appear as just "232" on your site is because the &, # and ; are stripped duruing import as part of the "normalisation" process that makes everything safe throughout the site.
If you want to permit these codes, it is probably safe to do so within the description field; however they should not be allowed in with the product name field as this will cause URL problems. To enable these codes for the description, find the following code on line 163 of includes/admin.php
$record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],",'\'\.%!");
..and change this as follows, by adding the characters you want to allow in the list...
$record[$admin_importFeed["field_description"]] = tapestry_normalise($record[$admin_importFeed["field_description"]],",'\'\.%!&#;");
Hope this helps,
Cheers,
David.