Jump to:

1851 Posts in 1606 Topics by 561 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: 687 Views
  • sajok
    Community Member
    82 Posts

    BlogTree entries on homepage? Link to this post


    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
    Forum Moderator
    5508 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.

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.