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

pull latest blogs into navigation.ss


Reply


2 Posts   696 Views

Avatar
zim

Community Member, 135 Posts

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

Avatar
zim

Community Member, 135 Posts

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