Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » [SOLVED] Publishing latest news on the homepage

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

Page: 1
Go to End
Author Topic: 1363 Views
  • clauer
    Avatar
    Community Member
    12 Posts

    [SOLVED] Publishing latest news on the homepage Link to this post

    Hi,

    I'm new to SilverStripe and I like the open concept. So I worked through the tutorials and now I'm stuck in tut 2.

    To publish the latest news on the homepage, I wrote the following function as described in the tut:

    class HomePage_Controller extends Page_Controller {
       function LatestNews($num=5) {
          $news = DataObject::get_one("NewsHolder");
          return ($news) ? DataObject::get("NewsPage", "ParentID = $news->id", "Date DESC", "", $num) : false;
          }
       
       }   

    Now when I address the homepage in the browser I get the error

    --> The website server has not been able to respond to your request.

    The entry in the Apache access.log looks like this:

    --> "GET /SilverStripe/ HTTP/1.1" 500 86

    Anyone who can get me on the right way? Thanks in advance.

    Christian

  • Willr
    Avatar
    Forum Moderator
    5502 Posts

    Re: [SOLVED] Publishing latest news on the homepage Link to this post

    try adding ' ' around the DBField

    function LatestNews($num=5) {
    $news = DataObject::get_one("NewsHolder");
    return ($news) ? DataObject::get("NewsPage", "ParentID = '$news->id'", "Date DESC", "", $num) : false;
    }

    Next thing you could try is turning the site into 'Devmode' by adding Director::set_environment_type("dev") to your _config.php file or Check your PHP error logs for a clue

  • clauer
    Avatar
    Community Member
    12 Posts

    Re: [SOLVED] Publishing latest news on the homepage Link to this post

    Thanks, obviously the quotes round the variable name $news->id are missing.
    Christian

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