Created
November 3, 2011 19:44
-
-
Save CNG/1337577 to your computer and use it in GitHub Desktop.
Movable Type two paragraph excerpt with php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$body = <<<EOT | |
<$mt:EntryBody encode_php="here"$> | |
EOT; | |
preg_match_all('#<p>(.+?)</p>#is', $body, $matches); | |
switch(count($matches[0])) { | |
case 0: break; | |
case 1: echo $matches[0][0]; break; | |
case 2: echo $matches[0][0].$matches[0][1]; break; | |
default: echo $matches[0][0]."<p>".$matches[1][1].' <a href="<mt:EntryPermalink>" class="actionlink">Read more »</a>'; break; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment