Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » pull latest blogs into navigation.ss

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 581 Views
  • zim
    Avatar
    Community Member
    135 Posts

    pull latest blogs into navigation.ss Link to this post

    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

  • zim
    Avatar
    Community Member
    135 Posts

    Re: pull latest blogs into navigation.ss Link to this post

    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

    581 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.