Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Latest forum topics

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

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

Page: 1
Go to End
Author Topic: 843 Views
  • grilldan
    Avatar
    Community Member
    135 Posts

    Latest forum topics Link to this post

    What I am trying to do is to get the last 5 forum topics, and the first 80characters of their topic text.

          <% if InSection(home) %>
           <div id="last_topics">
             <!-- get last topics-->
       <% if LatestPosts %>
                <% control LatestPosts(5) %>
                      <h2>Latest Questions</h2>
                      <h3>$Title</h3>
                      <p>$Content.LimitWordCount(80)</p>
                <% end_control %>
             <% else %>
                <h2>No Latest Questions</h2>
                <h3>No Title</h3>
                <p>No content</p>
             <% end_if %>
           </div>
          <% end_if %>

    I'm guessing something like that, but that code doesn't work.

    **edit**

    I got it working, now I'm trying to take out the bbcode, or parse it.

    I was working with this code to try to get it to parse.

          require_once('HTML/HTMLBBCodeParser.php');
          $this->content = DataObject::get('Post', '', 'Created DESC', '', (int)$limit);
          $this->content = (string)$this->content;
          $parser = new SSHTMLBBCodeParser();
          $parser->setText($this->content);
          $parser->parse();
          echo $parser->getParsed();

    **edit**
    Found what I needed here. Parse the code in the .ss file
    http://doc.silverstripe.com/doku.php?id=pear:bbcodeparser

  • Nivanka
    Avatar
    Community Member
    395 Posts

    Re: Latest forum topics Link to this post

    This is not difficult,
    Just see the codes of the Latest Forum Post Widget

    843 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.