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.

Blog Module /

Discuss the Blog Module.

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

BlogTree entries on homepage?


Reply


2 Posts   702 Views

Avatar
sajok

Community Member, 82 Posts

14 October 2010 at 1:48am

Hello,

I have set four main menu items as Blogtree page type, and under each blog tree I have other blogholders. I'm looking for a way to show the latest entries on the homepage exactly the same as what you see on blogTree page.

I was trying something like the following but it returned only entries from first blogHolder:

function LatestNews($id) {
$news = DataObject::get_one('BlogTree', "ParentID = $id");
return ($news) ? DataObject::get("BlogEntry", "ParentID = $news->ID", "Date DESC", "", 1) : false;
}

I would appreciate any help.. thanks

Avatar
Willr

Forum Moderator, 5513 Posts

28 October 2010 at 7:12pm

If you are trying to use <% control LatestNews($id) %> it won't work as the template engine doesn't support passing variables into functions.

One way if you want all the blog entries on the homepage is simply to use

function LatestNews() {
return DataObject::get("BlogEntry","", "Date DESC", "", 5);
}

To return the latest blog entries from anywhere.