SimplePortal
Development => Feature Requests => Topic started by: mforum on January 03, 2010, 05:23:27 AM
-
It would be nice to have a block that grabs a post and shows it with a Read More link.
We can put id of post and a limit in lines shown.
Now i use the following php block :
<?php $post = ssi_fetchPosts(148845, NULL, NULL);
echo $post[0]['body'], '<br />'; ?>
it just shows the whole post. :|
smf 2 rc2
SP 2.3.1
-
You try, please:
global $smcFunc;
$length = 50;
$post = ssi_fetchPosts(50, NULL, NULL);
if (!empty($length) && $smcFunc['strlen']($post[0]['body']) > $length)
{
$post[0]['body'] = $smcFunc['substr']($post[0]['body'], 0, $length);
// The first space or line break. (<br />, etc.)
$cutoff = max(strrpos($post[0]['body'], ' '), strrpos($post[0]['body'], '<'));
if ($cutoff !== false)
$post[0]['body'] = $smcFunc['substr']($post[0]['body'], 0, $cutoff);
$post[0]['body'] .= '<a href="' . $post[0]['href'] . '">...</a>';
}
echo $post[0]['body'];
-
Its perfect ! Thank you !! :thumbsup:
-
Hi
Just added the code in a custom php block but nothing is showing. Just empty. Is there something pertaining to my forum that i have to enter in the block code?