Jump to:

1016 Posts in 567 Topics by 309 members

Forum Module

SilverStripe Forums » Forum Module » [solved] Latest posts custom function

Discuss the Forum Module.

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

Page: 1
Go to End
Author Topic: 938 Views
  • NickJacobs
    Avatar
    Community Member
    144 Posts

    [solved] Latest posts custom function Link to this post

    Hi, I want to include the latest forum posts on a page outside the forum.

    this gets me the actual post data I need (title, content,create date):

    public function LatestIdeas() {

       return DataObject::get("Post","","ID desc","",5);

    }

    But I also want to include the Author name along with this....can anyone help with this??

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: [solved] Latest posts custom function Link to this post

    A post has a relationship with a member namely a author ID. So you can do $Author in the template gets you the Author object then you can do things like $Author.Nickname to get their nickname

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: [solved] Latest posts custom function Link to this post

    Thanks will.
    It all seems so straightforward when someone else spells it out for you....

    938 Views
Page: 1
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.