Hi again david , is there something i can add to a filter so the product name is only so many characters or words long , ie so the rest is dropped
cheers
Hi David
Sorry to bother you again.
I have just found this filter and it is exactly what I need but on some feed fields it is throwing up the following error
Warning: strpos() [function.strpos]: Offset not contained in string in (Path to) /filter.php on line 436
Warning: Cannot modify header information - headers already sent by (output started at (Path to) /filter.php:436) in
(Path to) /admin/feeds_import.php on line 31
$breakOffset = strpos($text," ",$filter_data["count"]);
Hi Ben,
Corrected above - this line:
if (strlen($text) > $length)
...should actually be:
if (strlen($text) > $filter_data["count"])
Cheers,
David.
--
PriceTapestry.com
Works a treat
Excellent Help as Always
Thanks
Ben
Hi Jonny,
Here is a new filter that will truncate a string on the next SPACE character after the specified limit (so that it doesn't break whole words). Add the following code to the end of your includes/filter.php file, just before the closing PHP tag:
/*************************************************/
/* Truncate */
/*************************************************/
$filter_names["truncate"] = "Truncate";
function filter_truncateConfigure($filter_data)
{
print "Character Limit:<br />";
print "<input type='count' size='40' name='count' value='".widget_safe($filter_data["count"])."' />";
widget_errorGet("count");
}
function filter_truncateValidate($filter_data)
{
if (!$filter_data["count"])
{
widget_errorSet("count","required field");
}
}
function filter_truncateExec($filter_data,$text)
{
if (strlen($text) > $filter_data["count"])
{
$breakOffset = strpos($text," ",$filter_data["count"]);
if ($breakOffset !== false)
{
$text = substr($text,0,$breakOffset).$append;
}
}
return $text;
}
Cheers,
David.
--
PriceTapestry.com