[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [ic] return section of text that contain search term


> I would like to return a section of text in context around a 
> search term.  I am wondering if anyone has done this.  I 
> could have sworn I had seen something like this before on
> an earlier version of the ICDEV site, but maybe not.  What
> I am going for is something similar to what Google does 
> on their results, only not as jazzy -- I just do not want to 
> return the whole db value as it may be quite long ....
> 
> Has anyone done this?  Any ideas on it? input? direction?

Assuming you are returning something like [item-description] from
your search. Something like this would work if I understand your
question correctly.

[calc]
# Set the maximum length of the string you want to display
$max_length = 25;
$out = q{[item-description]};
if (length($out) > $max_length) {
	$out = substr($out,0,$max_length);
      # In case we chopped up a word, backup to the last space
	$out =~ s/ [^ ]*$//;
      # add some ... to the end of the string
	return $out . " ..."; 
}
return $out;
[/calc]

Think this is what you want...

Jerry

_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.