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.

Template Questions /

Latest News show all in News section


Reply


2 Posts   1132 Views

Avatar
clschnei

Community Member, 2 Posts

29 September 2010 at 5:35am

I am using and Article Holder to show the latest news for a website, but I only wish to show the first three. Right now it is showing every article in the News section.

Is there anyway to only show the first 3?

Avatar
3dgoo

Community Member, 133 Posts

29 September 2010 at 2:42pm

http://doc.silverstripe.org/tutorial:2-extending-a-basic-site#showing_the_latest_news_on_the_homepage

function LatestNews($num=3) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}

<% control LatestNews %>
$Content
<% end_control %>