17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1879 Views |
-
FirstSentence method problem

4 October 2008 at 3:55am
Hi
I have a problem with using the first sentence method to get the start of news item content as detailed in the tutorials.If
I have an image in the news item content that is added using the CMS editor image functionalityAnd
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 sentenceThis is not what I want this method to do!
-
Re: FirstSentence method problem

4 October 2008 at 6:39am
The FirstSentence() method is in:
sapphire/core/model/fieldtypes/Text.php
function FirstSentence() {
$data = Convert::xml2raw( $this->value );
$sentences = explode( '.', $data );
if( count( $sentences ) )
return $sentences[0] . '.';
else
return $this->Summary(20);
}I think my inclination would be to change the line
to$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.
| 1879 Views | ||
|
Page:
1
|
Go to Top |

