17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1272 Views |
-
Tutorial 2: Ordering the news and number of displayed items

15 August 2008 at 3:32pm
Hi guys,
Maybe I've been awake too long staring at this screen but I swear I cannot see anywhere in Tutorial 2 that shows how to order the news posts!
The problem I have: Using the news post setup (exactly as show in tutorial 2), whenever I create a new ArticlePage it orders itself (in the CMS and on the news page) under the previous posts... how do I get them to run in order from most recently posted to oldest?
Also... is there a way (already documented preferably) to show say.. the last 10 news items only, and have the rest off the page in record sets (im not sure if thats the right terminology sorry), eg: small number at the bottom of them page where you can go back and see previously posted news.
Thanks in advance....
-
Re: Tutorial 2: Ordering the news and number of displayed items

15 August 2008 at 5:03pm
I think it shows this code in the tutorial
DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num).
Which translates to
GET ALL of the 'ArticlePages' whose Parent = X. Order it by the Date Desc. And $num is the limit of how much you want to limit it to. If you want all the pages you can just get rid of the last parameter - this will get all. If you make $num 10 then it will get the latest 10.
So the format in SQL terms is
DataObject::get( <TYPE OF PAGE>, <FILTER>, <SORT OPTION>, <JOIN OPTION>, <LIMIT>);
Join is more compilcated so you can leave it blank. See http://doc.silverstripe.com/doku.php?id=datamodel&s=dataobject
-
Re: Tutorial 2: Ordering the news and number of displayed items

15 August 2008 at 5:26pm
Thanks mate, got it sorted now with your help!
| 1272 Views | ||
|
Page:
1
|
Go to Top |

