Return to Snippet

Revision: 40388
at February 1, 2011 07:01 by ericmuyser


Initial Code
$content = $post->content;
    
    if(preg_match_all('#<p>(.*)</p>#simU', $content, $m1, PREG_SET_ORDER) && count($m1) >= 2) { // more than 2 paragraphs
      $trim = $site_settings->blog->preview->trim_length;
      $l_1 = strlen($m1[0][1]);
      $l_2 = strlen($m1[1][1]);
     
      if($l_1 < ($trim * 0.75) && $l_2 < $trim) {
        $content = '<p>' . $m1[0][1] . '</p>' . '<p>' . $m1[1][1] . '</p>';//substr($content, 0, $l_1 + $l_2 + 7 + 7 + 2);
      }
      else if($l_1 < $trim) {
        $content = '<p>' . $m1[0][1] . '</p>'; //substr($content, 0, $l_1 + 7);
      }
      else {
        $content = '<p>' . substr($m1[0][1], 0, $trim) . ' ...</p>';
      }
    }

Initial URL

                                

Initial Description

                                

Initial Title
ls smart blog excerpt

Initial Tags

                                

Initial Language
PHP