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.
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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.
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 %>
That is a good idea but it doesn't work. It returns nothing.
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)