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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Showing latest news on homepage


Go to End


3 Posts   1575 Views

Avatar
patrickholzer

Community Member, 4 Posts

26 November 2010 at 11:30pm

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!

Avatar
swaiba

Forum Moderator, 1899 Posts

26 November 2010 at 11:59pm

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

Avatar
bartvanirsel

Community Member, 96 Posts

27 November 2010 at 2:10am

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.