Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Showing latest news on homepage

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

Page: 1
Go to End
Author Topic: 908 Views
  • patrickholzer
    Avatar
    Community Member
    4 Posts

    Showing latest news on homepage Link to this post

    Hi,

    I've been implementing this function here successfully on mysite/code/HomePage.php:
    ...
    function LatestNews($num=5) {
    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }
    ...

    Now, I tried to implement the same function on the HomePage.php, but instead with News from the "EventHolder":
    ...
    function LatestEvents($num=5) {
    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }
    ...

    I could successfully update the database and everything seems to work, except the homepage is not being rendered anymore at all, the page says: "Sorry, there was a problem with handling your request."

    Where's the mistake?

    Thanks!

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: Showing latest news on homepage Link to this post

    Is that your actual code? It looks like 'LatestEvents' still uses 'ArticleHolder' and 'ArticlePage'...

  • bartvanirsel
    Avatar
    Community Member
    94 Posts

    Re: Showing latest news on homepage Link to this post

    Try turning on dev mode to see more errors.

    Why dont you create one method in the Page class? That way both Homepage.php and NewsHolder.php can use it.

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