Hi David
I'm a new user of pricetapestry and thank you for making this nice script available.
On a feed from tradedoubler I get categories like :
Lighting/Wall Lanterns/Sea Gull Lighting
And i would like to keep only the last string after "/" :
Sea Gull lighting
I've searched on the forum and I tried the filters you indicated on this page :
http://www.pricetapestry.com/node/320
/*************************************************/
/* splitBefore */
/*************************************************/
$filter_names["splitBefore"] = "Split Before";
function filter_splitBeforeConfigure($filter_data)
{
print "Split Character or String:";
print "";
widget_errorGet("text");
}
function filter_splitBeforeValidate($filter_data)
{
if (!$filter_data["text"])
{
widget_errorSet("text","required field");
}
}
function filter_splitBeforeExec($filter_data,$text)
{
return trim(substr($text,strpos($text,$filter_data["text"])));
}
Many thanks for your help,
Best regards,
Fred
Hi David,
Thanks for your answer. I've tried this filter too but it doesn't work either. Both filters seem to work with other string, like an alphabet character. The slash character maybe the problem. I noticed that in the Product table I can see that in the field "category" the slash don't appear. Maybe there is a script that removes the slash before the filter is applied ?
For instance :
Femme Pantalon / Pantalon citadin
has become in the database :
Femme Pantalon pantalon citadin
Best regards,
Frédéric
Hi Frédéric,
My apologies - yes / is stripped by the standard filters. To fix this, look for the following code on line 166 of includes/admin.php...
$importRecord["category"] = tapestry_normalise($importRecord["category"]);
...and REPLACE with:
$importRecord["category"] = tapestry_normalise($importRecord["category"],"\/");
That will permit the / character so that it can be used by the subsequent user filter...
Cheers,
David.
Hi David,
No problem, it's nice to get so quick answers. I did modify the "includes/admin.php" file but I get now some error messages :
Warning: preg_replace() [function.preg-replace]: Unknown modifier ']' in /home/acheter/www/beta/includes/tapestry.php on line 27
Warning: explode() [function.explode]: Empty delimiter in /home/acheter/www/beta/includes/filter.php on line 380
These errors messages are repeated many times, and at the end of the file I get this error message :
Warning: Cannot modify header information - headers already sent by (output started at /home/acheter/www/beta/includes/tapestry.php:27) in /home/acheter/www/beta/admin/feeds_import.php on line 31
Best regards,
Frédéric
Hi Frédéric,
Could you email me a link to your site (and any password required for /admin/), the name of the feed that you are using this filter with; and also the following files as attachments...
includes/admin.php
includes/filter.php
...i'll check it all out for you...
Cheers,
David.
Please post the solution to this, as I am encountering the exact same problems.
Thanks
Hi,
Are you getting the
Unknown modifier ']' in /home/acheter/www/beta/includes/tapestry.php on line 27
error?
...or something else?
The unknown modifier error turned out to be a result of the text editor corrupting the file; so wouldn't ordinarily be a problem.
As above, if you could email me your modified includes/filter.php, the URL of your installation, and filename of the feed that is causing the error i'll check it out for you...
Cheers,
David.
Hi Fred,
It would be easier I think with the Explode filter from this post:
http://www.pricetapestry.com/node/2017#comment-8036
If you add that code to your includes/filter.php, and then add a new Explode filter to your category field for this feed; using a split character of "/" and return index of -1 will return the last value in the list..
Hope this helps!
Cheers,
David.