Discussion Preview?
How hard would it be to get a summary of the post listed on the main page under the topic? Like the first 300 words or so.
Has this been mentioned in any other threads?
I was dabbling around with this a little earlier and was curious. Can it be done with just a simple theme change? Or would it be best to just do it as an extension? I am thinking extension would probably benefit everyone more. I need it for a theme I am working on.
Any ideas? Where would be a good place to start?
Has this been mentioned in any other threads?
I was dabbling around with this a little earlier and was curious. Can it be done with just a simple theme change? Or would it be best to just do it as an extension? I am thinking extension would probably benefit everyone more. I need it for a theme I am working on.
Any ideas? Where would be a good place to start?
0
This discussion has been closed.
Comments
Not exactly using the same words though.. disregard this post.
Anyone?
this isnt a foolproof way but it'll work none the less
$string = 'find your own string...'; $string = explode(' ', $string); echo implode(' ', array_splice($string, 0, 300));function getpreview($text, $len) { if(strlen($text) <= $len) return $text; //first check to see if we can seperate paragraphs for($i = $len; $text[$i] != "\n" && $text[$i] != "\r" && $i > 0; $i--) ; for(; $text[$i] == "\r" || $text[$i] == "\n" && $i > 0; $i--) ; if($i > 0) return substr($text, 0, $i + 1); //now try punctuation for($i = $len; !ctype_punct($text[$i]) && $i >= 0; $i--) ; if($i > 0) return substr($text, 0, $i + 1) . ' ...'; //and lastly, any spaces for($i = $len; !ctype_space($text[$i]) && $i >= 0; $i--) ; if($i > 0) return substr($text, 0, $i) . ' ...'; //if none of the above, just return a substring return substr($text, 0, $len) . ' ...'; }