Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

17480 Posts in 4474 Topics by 1973 members

Archive

SilverStripe Forums » Archive » Getting latest forum posts

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

Page: 1
Go to End
Author Topic: Getting latest forum posts 274 Views
  • grilldan
    avatar
    Community Member
    132 posts

    Getting latest forum posts Link to this post

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

    274 Views
Page: 1
Go to Top

Currently Online: beeonline, xterso, robinp, _Vince

Welcome to our latest member: marcusl

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.