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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

DataObject - Getting latest forum posts.


Go to End


10 Posts   3620 Views

Avatar
Josh

SilverStripe Developer, 65 Posts

18 July 2008 at 12:49pm

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);

Avatar
Willr

Forum Moderator, 5523 Posts

18 July 2008 at 1:48pm

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

Go to Top