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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Blog Module /

Discuss the Blog Module.

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

pull latest blogs into

Go to End

2 Posts   972 Views


Community Member, 135 Posts

10 May 2011 at 8:11am

I am trying desperately to pull latest blogs into my include file. but so far with no success.

i have.

function LatestBlogPosts($num=5) {
$blogs = DataObject::get_one("BlogHolder");
return ($blogs) ? DataObject::get("BlogEntry", "ParentID = $blogs->ID", "Date DESC", "", $num) : false;

in my page.php


<% if ClassName = BlogHolder %>

<% if LatestBlogPosts(4) %>

<% control LatestBlogPosts(4) %>


<% end_control %>

<% end_if %>

<% end_if %>


but not working.

can anyone advise where i am going wrong please.



Community Member, 135 Posts

10 May 2011 at 8:59am

Solves this by putting

static $allowed_children = array(

function LatestBlogs($num=5) {
return DataObject::get("BlogEntry", "", "Date DESC", "", $num);

in top part of page.php


<% control LatestBlogs(3) %>

<a href="$Link">$MenuTitle</a>

<% end_control %>

in include file