Amount of words in the list view. Noob needs help!

2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 23, 2008   (RSS)

Re: [ventana] Amount of words in the list view. Noob needs help!

By Dave - January 23, 2008

Hi Ventana, welcome aboard!

There's two ways to do that. The simplest is just to have a 'summary' field. This lets the user have complete control over what's in the summary. And you can set a max character limit on the field as well.

Next, the PHP code version, as requested:

Instead of this:

<?php echo $record['content'] ?>

Try this:

<?php
$maxWords = 3;
$words = explode(" ", $record['content']);
$words = array_slice($words, 0, $maxWords);
$summary = join(" ", $words);
print $summary;
?>


That splits up the content on spaces and then output the first three words (or however many you specify).

Hope that helps! :)
Dave Edis - Senior Developer
interactivetools.com