Hi David,
I am trying to delete filter after a word filter after split doesn't work for me:
nike 123
nike 234
nike 4556
Delete everything after nike?
Thx
Henk
Hi David,
Almost i think but it stripped it to 5 letters the complete import of all brands
Thx
Henk
Hi Henk,
Made conditional to the search string being found, in the code above...
Cheers,
David.
--
PriceTapestry.com
Hi David,
Now it doesn't delete after a name or does anything?
Thx
Henk
Hi Henk,
Should be OK now - added !== test to handle match string appearing at start...
Cheers,
David.
--
PriceTapestry.com
Hi David,
Is it moaybe also possible to do it quicker like the mapped products idea only on brands?
Thx
Henk
Hi Henk,
There's a "Split Before" filter in this thread which it sounds like you may have already found, but in this example, that would also remove "Nike" of course; however the code can be easily modified to include the "split" string in the return value. Have a go with the following, based on the filter from the other thread but renamed "Delete After":
<?php
/*************************************************/
/* deleteAfter */
/*************************************************/
$filter_names["deleteAfter"] = "Delete After";
function filter_deleteAfterConfigure($filter_data)
{
print "Delete After Character or String:<br />";
print "<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
widget_errorGet("text");
}
function filter_deleteAfterValidate($filter_data)
{
if (!$filter_data["text"])
{
widget_errorSet("text","required field");
}
}
function filter_deleteAfterExec($filter_data,$text)
{
$p = stripos($text,$filter_data["text"]);
if ($p!==FALSE)
{
$text = substr($text,0,$p+strlen($filter_data["text"]));
}
return $text;
}
?>
I've made the above case-insensitive by using stripos, so "nike" or "Nike" will match, but if you wanted to keep case sensitivity then just change stripos to strpos.
Hope this helps!
Cheers,
David.
--
PriceTapestry.com