Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Extending a basic site

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

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

Page: 1
Go to End
Author Topic: 561 Views
  • Henry24
    Avatar
    Community Member
    9 Posts

    Extending a basic site Link to this post

    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

  • stallain
    Avatar
    Community Member
    61 Posts

    Re: Extending a basic site Link to this post

    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

    561 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.