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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Combine.BigSummary with NoHTML


Go to End


4 Posts   1850 Views

Avatar
Deklin

Community Member, 16 Posts

15 July 2010 at 3:17pm

I want to display roughly the first 50 characters WITHOUT html.

This does NOT work:

$Content.NoHTML.BigSummary(22)

The problem with BigSummary is that it returns content inside of HTML tags.

Avatar
Willr

Forum Moderator, 5523 Posts

15 July 2010 at 7:08pm

The template parser doesn't support chaining methods like that. You may be able to do something like

<% control Content %>$NoHTML.BigSummary(22)<% end_control %>

Avatar
Deklin

Community Member, 16 Posts

16 July 2010 at 12:26am

That is a good idea but it doesn't work. It returns nothing.

Avatar
Willr

Forum Moderator, 5523 Posts

16 July 2010 at 9:03am

Damn what a shame I thought it would. It *should* work in my head but I guess it doesn't. So you'll have to write your own bit of PHP for this.

In the model of the object you want to use that on (eg Page) try the following function. This saves the value generated by NoHTML as a Text object so you can then call BigSummary on it

function getNoHTMLContent() {

$nohtml = DBField::create('Text', $this->dbObject('Content')->NoHTML());

return $nohtml;

Then because that returns a Text object you should be able to call $NoHTMLContent.BigSummary(22)