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

Getting latest forum posts


Go to End


1068 Views

Avatar
grilldan

Community Member, 135 Posts

1 October 2008 at 4:58pm

Edited: 01/10/2008 5:50pm

Does anyone know of a way to get the latest fourm posts to display on the homepage? I have tryed several ways, but I can only get the last post. If I try to get more then the last post, I get a memory error. (Fatal error: Out of memory (allocated 28049408) (tried to allocate 4864 bytes)...)

Here is some of the code I have been working with:

	function LatestPosts() {
		//$this->content = DataObject::get('Post', '', 'Created DESC', '', (int)$limit);
		//return $this->RecentPosts(5);	
		//return "error";
		//return DataObject::get('Post', '', 'Created DESC', '', (int)$limit); 	                    
        //return DataObject::get("Post", "", "Created DESC", "", 0,5);
			$posts = DataObject::get("Post", "", "Created DESC", "" , "1");
			if($posts){
				return $posts;
			}
			else{
				return null;
			}		
	}	

**UPDATE**
I got it working with this code

			$posts = DataObject::get("Post", "Content != ''", "Created DESC", "" , "5");
			if($posts){
				return $posts;
			}
			else{
				return null;
			}