Hi iraira88
You'll have to create a custom function for your BlogEntry class to get the functionality you want. Start by creating a DataExtension of the BlogEntry class.
I've included some code I used in an old 2.4 project. it is untested in 3.0 so may require some modification.
class BlogEntryExtension extends DataExtension {
/**
* Returns a Summary of the content but retains links (including the pesky site_tree_id links)
* also removes images.
* @return (string)
**/
public function getCustomSummary($maxWords = 35){
$content = $this->obj('Content');
$data = (string)$content->forTemplate();
$data = strip_tags($data, '<a>');
// grab the first paragraph, or, failing that, the whole content
if( strpos( $data, "\n\n" ) )
$data = substr( $data, 0, strpos( $data, "\n\n" ) );
$sentences = explode( '.', $data );
$count = count( explode( ' ', $sentences[0] ) );
// if the first sentence is too long, show only the first $maxWords words
if( $count > $maxWords ) {
return implode( ' ', array_slice( explode( ' ', $sentences[0] ), 0, $maxWords ) ).'...';
}
// add each sentence while there are enough words to do so
$result = '';
do {
$result .= trim(array_shift( $sentences )).'.';
if(count($sentences) > 0) {
$count += count( explode( ' ', $sentences[0] ) );
}
// Ensure that we don't trim half way through a tag or a link
$brokenLink = (substr_count($result,'<') != substr_count($result,'>')) ||
(substr_count($result,'<a') != substr_count($result,'</a'));
} while( ($count < $maxWords || $brokenLink) && $sentences && trim( $sentences[0] ) );
if( preg_match( '/<a[^>]*>/', $result ) && !preg_match( '/<\/a>/', $result ) )
$result .= '</a>';
return $result;
}
}
and then in your _config.php add
Object::add_extension('BlogEntry','BlogEntryExtension');
and in BlogSummary.ss use $CustomSummary instead of $Content.LimitWordCountXML. Hope that helps.