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.

Forum Module /

Discuss the Forum Module.

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

[solved] Latest posts custom function


Reply


3 Posts   1007 Views

Avatar
NickJacobs

Community Member, 144 Posts

13 August 2009 at 12:35pm

Edited: 14/08/2009 7:09am

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??

Avatar
Willr

Forum Moderator, 5513 Posts

13 August 2009 at 5:59pm

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

Avatar
NickJacobs

Community Member, 144 Posts

14 August 2009 at 7:10am

Edited: 14/08/2009 7:10am

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