Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

[SOLVED] Publishing latest news on the homepage


Reply

3 Posts   1373 Views

Avatar
clauer

16 January 2009 at 8:54am (Last edited: 17 January 2009 10:40am), Community Member, 12 Posts

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

Avatar
Willr

16 January 2009 at 4:50pm Forum Moderator, 5511 Posts

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

Avatar
clauer

17 January 2009 at 10:39am Community Member, 12 Posts

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