Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Combine.BigSummary with NoHTML

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

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

Page: 1
Go to End
Author Topic: 955 Views
  • Deklin
    Avatar
    Community Member
    16 Posts

    Combine.BigSummary with NoHTML Link to this post

    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.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Combine.BigSummary with NoHTML Link to this post

    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 %>

  • Deklin
    Avatar
    Community Member
    16 Posts

    Re: Combine.BigSummary with NoHTML Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Combine.BigSummary with NoHTML Link to this post

    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)

    955 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.