3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 899 Views |
-
Show only 5 News on one Page

30 July 2010 at 12:30am Last edited: 30 July 2010 12:35am
Hello everyone,
I started using silverstripe 3 weeks ago.
I build a little news system and now I have a "problem", which I can't fix.
I have a NewsHolder.php which extends the Page class
class NewsHolder extends Page
{
//...
static $has_many = array (
'News' => 'News'
);
//...
}class NewsHolder_Controller extends Page_Controller
{}
At the moment the content shows all news. But I want only 5 news and a link on the bottom of the page to view the next 5 news.
I wrote a function which I put in the NewsHolder_Controller:
function getNews ()
{
if (!isset($this->urlParams['ID']) || $this->urlParams['ID'] == 0)
$start = 0;
else
$start = $this->urlParams['ID']*10;
$news = DataObject::get("News",'','','',array($start,10));
}Now I dont know how to move forward? When I am load http://localhost/mypage/news/1 (mypage is the silverstripe base folder and news the page name which uses the newsholder), I the error page. I don't want to use http://localhost/mypage/news/getNews/1 to switch the news.
Can someone help me?
Thank you
Bez -
Re: Show only 5 News on one Page

5 August 2010 at 1:01pm
Have a look at this:
http://doc.silverstripe.org/private:recipes:pagination
Let me know if you have any questions.
| 899 Views | ||
|
Page:
1
|
Go to Top |


