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.

Archive

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

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

Latest forum topics


Reply

2 Posts   862 Views

Avatar
grilldan

29 September 2008 at 5:12pm (Last edited: 29 September 2008 7:40pm), Community Member, 135 Posts

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 :)
[url]http://doc.silverstripe.com/doku.php?id=pear:bbcodeparser[/url]

Avatar
Nivanka

29 September 2008 at 10:39pm Community Member, 395 Posts

This is not difficult,
Just see the codes of the [url=http://ssopen.ernie.silverstripe.com/Latest-Forum-Post/]Latest Forum Post Widget[/url]