Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

FirstSentence method problem

Go to End

2 Posts   2628 Views


Community Member, 23 Posts

4 October 2008 at 3:55am

I have a problem with using the first sentence method to get the start of news item content as detailed in the tutorials.

I have an image in the news item content that is added using the CMS editor image functionality

if it appears as the first part of the content before the actual text, the FirstSentence method is stripping out the value if the image title attribute from within the <img> tag and using this as the beginning of the first sentence

This is not what I want this method to do!


Community Member, 10 Posts

4 October 2008 at 6:39am

The FirstSentence() method is in:


	function FirstSentence() {
		$data = Convert::xml2raw( $this->value );
		$sentences = explode( '.', $data );
		if( count( $sentences ) )
			return $sentences[0] . '.';
			return $this->Summary(20);

I think my inclination would be to change the line

$data = Convert::xml2raw( $this->value );
$data = strip_tags($this->value );

Though I have not tested that. It looks like FirstSentence just looks for periods to find that first sentence though, so if you had Mr. Blandings builds his dreamhouse. The first sentence would be "Mr."

I'd be more inclined to add a "First sentence" field in the database and CMS and manage the excerpt yourself.