Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » DataObject - Getting latest forum posts.

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: 2756 Views
  • Josh
    Avatar
    SilverStripe Developer
    65 Posts

    Re: DataObject - Getting latest forum posts. Link to this post

    Sorry, guess I should have said that I am now using the RecentPosts() code from ForumHolder.

    function NewPosts($limit = null, $lastVisit = null,
                                         $lastPostID = null) {
                                           
             $filter = "";

             if($lastVisit)
                $lastVisit = @date('Y-m-d H:i:s', $lastVisit);

             $lastPostID = (int)$lastPostID;
             if($lastPostID > 0)
                $filter .= "ID > $lastPostID";

             if($lastVisit) {
                if($lastPostID > 0)
                   $filter .= " AND ";

                $filter .= "Created > '$lastVisit'";
             }

             return DataObject::get("Post", $filter, "Created DESC", "", 8);

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: DataObject - Getting latest forum posts. Link to this post

    you might just like to comment out each line or whole chunks to see what is actually causing the error / see if you could get it to work with all the $filter stuff commented out. Cut out as much as you can to get it to work then work backwards by adding bits back and seeing when it breaks

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