Jump to:

1842 Posts in 1600 Topics by 558 members

Blog Module

SilverStripe Forums » Blog Module » BlogTree entries on homepage?

Discuss the Blog Module.

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

Page: 1
Go to End
Author Topic: 680 Views
  • sajok
    Avatar
    Community Member
    82 Posts

    BlogTree entries on homepage? Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: BlogTree entries on homepage? Link to this post

    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.

    680 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.