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

Blog Entry on Homepage


Go to End


3 Posts   1806 Views

Avatar
redking

43 Posts

28 May 2008 at 8:50am

Hi,

Does anyone know how to make the most recent entry from the blog module display on the homepage. I had done this with the new section before, but can't seem to figure out how to do it with the blog. Any ideas?

Thanks!

Avatar
Sean

Forum Moderator, 922 Posts

28 May 2008 at 10:01am

Edited: 28/05/2008 10:01am

Adding this function to your HomePage_Controller should work...

function getLatestPost() {
   return DataObject::get_one('BlogEntry', '', false, 'LastEdited DESC');
}

Then you can call $LatestPost.Title and so forth in the template.

Avatar
redking

43 Posts

28 May 2008 at 10:43am

Edited: 28/05/2008 10:43am

Worked. Right on! Thanks, man :)