Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » why is the blog summary paragraph injecting line breaks?

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

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

Page: 1 2
Go to End
Author Topic: 5375 Views
  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: why is the blog summary paragraph injecting line breaks? Link to this post

    I didn't need it, but it's a good idea. I didn't test all the scenarios where the line breaks are added and it is entirely possible that there are some where spaces are stripped.

  • hendy
    Avatar
    Community Member
    2 Posts

    Re: why is the blog summary paragraph injecting line breaks? Link to this post

    Thanks so much for this fix, Hamish. It was a very annoying problem for me. I also needed a sentence summary of each post, so I adapted your fixed function:

    function SentenceSummary(){
       $content = new Text('Content');
       $content->value = Convert::raw2xml($this->Content);
       $firstParagraph = preg_replace( '/((\n)|(\r))/', ' ', $content->FirstSentence());
       $parser = new BBCodeParser($firstParagraph);
       return $parser->parse();   
    }

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: why is the blog summary paragraph injecting line breaks? Link to this post

    In trac it appears this has been fixed properly, although it hasn't made it to release. This is the newer fix, which should work without the dodgy preg_replace's.

    $parser = new BBCodeParser($this->Content);
    $html = new HTMLText('Content');
    $html->setValue($parser->parse());
    return $html->FirstParagraph('html');

    Still waiting for an official next release of the blog module.. maybe they just assume that everyone uses subversion?

    5375 Views
Page: 1 2
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.