1770 Posts in 495 Topics by 531 members
Blog Module
SilverStripe Forums » Blog Module » pull latest blogs into navigation.ss
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 474 Views |
-
pull latest blogs into navigation.ss

10 May 2011 at 8:11am
I am trying desperately to pull latest blogs into my navigation.ss 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
and
<% if ClassName = BlogHolder %>
blog<% if LatestBlogPosts(4) %>
<% control LatestBlogPosts(4) %>
$Title<% end_control %>
<% end_if %>
<% end_if %>in navigation.ss
but not working.
can anyone advise where i am going wrong please.
thanks
-
Re: pull latest blogs into navigation.ss

10 May 2011 at 8:59am
Solves this by putting
static $allowed_children = array(
'BlogEntry'
);
function LatestBlogs($num=5) {
return DataObject::get("BlogEntry", "", "Date DESC", "", $num);
}in top part of page.php
and
<% control LatestBlogs(3) %>
<a href="$Link">$MenuTitle</a>
<% end_control %>
in navigation.ss include file
| 474 Views | ||
|
Page:
1
|
Go to Top |

