Tomasz
|
Posted: 01/05/2002, 10:57 AM |
|
on codecharge newsgroup there was a thread about limiting field view (in december,Subject: Re: More (teaser) / partial field view)
I've changed script from 'webmaster' - now it recognize spaces and don't cut words in a middle. But - for unknown reason - function used in CC page doesn't work on some condition. I've call it "unknown" becouse function used on php page outside CC works ok.
script is (in modules/global):
function myArticleShow($article_desc,$url) {
return myArticleShowConvert($article_desc).'... ' .
'[<a href="'.$url.'"> more </a>]';
}
function myArticleShowConvert($str, $index=10, $char=" ") {
while (substr($str, $index, 1)!=$char) $index++;
return substr($str, 0, $index);
}
and it's called on page in Show Event :
$fldnews_text = myArticleShow($fldnews_text, "news_view.php?message_id=$fldmessage_id");
$index=10 is a number of chars.
And when I use more than... 17 chars, I receive:
Fatal error: Maximum execution time of 30 seconds exceeded in common.php on line
258
function appears to be ok, becouse on static php page outside CC I can use any numer of chars. What can be wrong?
|
|
|
Brent
|
Posted: 01/05/2002, 11:12 PM |
|
You have a potential infinite loop in:
while (substr($str, $index, 1)!=$char) $index++;
That's why it is timing out. What happens if the last character in the $str is
not a blank? It will loop forever because the substr() will
return an empty string "" and "" <> " " so it loops forever.
|
|
|
|