Submitted by philstone on Fri, 2006-06-09 12:00 in Price Tapestry
Hi dave
was wondering, you know the way the split filter deletes everything after a certain value set by the user, is there anyway for this to delete everything before the split value in a different option?
This filter isn't in the distribution, but you should be able to make a copy of the split filter with a new name and the appropriate modification to cut the text before the value set by the user.
The code would be as follows:
<?php /*************************************************/ /* splitBefore */ /*************************************************/ $filter_names["splitBefore"] = "Split Before"; function filter_splitBeforeConfigure($filter_data) { print "Split Character or String:<br />"; print "<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />"; 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"]))); } ?>
Hi Phil,
This filter isn't in the distribution, but you should be able to make a copy of the split filter with a new name and the appropriate modification to cut the text before the value set by the user.
The code would be as follows:
<?php
/*************************************************/
/* splitBefore */
/*************************************************/
$filter_names["splitBefore"] = "Split Before";
function filter_splitBeforeConfigure($filter_data)
{
print "Split Character or String:<br />";
print "<input type='text' size='40' name='text' value='".widget_safe($filter_data["text"])."' />";
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"])));
}
?>
That should do the trick...!
Cheers,
David.