Blog Entries with different lengths of info

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 6, 2012   (RSS)

By crazyfish - December 6, 2012 - edited: December 6, 2012

A client has a blog, most are short and sweet but every now and then, the content goes on forever - and they add images. This is for a list page.

So, how do I let short ones run, and long ones have a link to a details page?

Logic something like this:

<?php if ($record['content']$maxwords > 25): ?>
show 25 words then link<br/><br/>
<?php endif ?>

else show the entire post and no link

( really it's the first line of the code that has me stumped )
Thanks in advance!

Re: [greg] Blog Entries with different lengths of info

By crazyfish - December 6, 2012

Awesome. The problem was it is indeed a WYSIWYG editor and there were links, paragraphs etc in the section. So I took your code and changed it a bit to work for guys like me!

<?php if(str_word_count($record['content']) > 100): ?>
<?php echo maxWords($record['content'], 50); ?>...<br />
<a href="<?php echo $record['_link'] ?>">[ Read More ]</a><br/>
<?php else: ?>
<?php echo $record['content']; ?><br>
<?php endif; ?>


Thank you for your quick response and excellent help.