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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Extending a basic site


Go to End


2 Posts   1223 Views

Avatar
Henry24

Community Member, 9 Posts

12 May 2011 at 6:33pm

hi guys,

I've used this tutorial to create a page a news page

http://doc.silverstripe.org/sapphire/en/tutorials/2-extending-a-basic-site

however I have a problem with the articleholder not displaying the pages sorted by descending date, rather its showing by how its sorted in the admin panel

this is the current code i use for the articleholder.php page

<?php
/**
 * Defines the ArticleHolder page type
 */
class ArticleHolder extends Page {
    static $db = array(
    );
    static $has_one = array(
    );
    
    static $allowed_children = array('ArticlePage');
}
  
class ArticleHolder_Controller extends Page_Controller {
     function rss() {
        $rss = new RSSFeed($this->Children(), $this->Link(), "BBY News");
        $rss->outputToBrowser();
    }
}
  
?>

the blog module sorts by date but i cant seem to be able to figure out how to do it with the news page

cheers

Avatar
stallain

Community Member, 68 Posts

11 June 2011 at 11:44am

Hi Henry,

A function like this one should work (in your ArticleHolder controller) :

function GetArticles() {
return DataObject::get("ArticlePage", "", "Date DESC", "", "");}

(assuming $Date is the name of your date field in your ArticlePage db)

Then, in your ArticleHolder.ss page, you can retrieve your posts within a <% control GetArticles %> loop.

Stan