Hello and shortly direct to the problem with my own solution to shorten your string and ending after the next possible word. You have to choice your layout template, which you are use and have configurated. I use the “Layout 1” so I look in the “layout1.php” at “lib”->”views”->”layouts” at line 46.
Note: your Post Grid layout setting (excerpt limit) is minimum as like as our following limit number or better leave it blank. Have fun, David Harex ??
if(in_array('excerpt', $items)){
//old original
//$html .= "<div class='post-content'>{$excerpt}</div>";
/*limit the string, choice a bigger number as in your excerpt number at the preferences!*/
$limit=200;
//PHP wordwrap shorten strings without to cut in two
$text = wordwrap($excerpt, $limit, "\0");
//every 200 letters we put an ASCII Code No. 0 in it. This is a realy seldom used sign and here helpfully.
/*
divide th string. The (.*?) means all signs before the first ASCII sign and the (.*) stands for all after. The \0 repeats often but we tell them with a "?" in de ending first part, that here is the end of our shortend string. The other part is uninterested for us. And now we have our limited string.
*/
$newshortstring= preg_replace('/^(.*?)\0(.*)$/is', '$1', $text);
$html .= "<div class='post-content'>$newshortstring...</div>";
}
/*END :-D */
-
This reply was modified 7 years, 9 months ago by davidharex.
-
This reply was modified 7 years, 9 months ago by davidharex.