Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Archive the news?

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1937 Views
  • abelcreative
    4 Posts

    Archive the news? Link to this post

    I installed this for a client - and now they're asking for a way to archive their news. Any way to do that?

  • Sam
    679 Posts

    Re: Archive the news? Link to this post

    The easier is to create a different page called "news archive", and get your client to drag the old pages into that.

    If you want to do it automatically, you could write a different Children() method on your news page that only listed the 10 most recent items, and an ArchiveChildren() method that will return older items:

    function Children() {
    // return the current items;
    function ArchiveChildren() {
    // return archived items

    function archive() {
    return array(
    "Children" => $this->ArchiveChildren(),

    That way, you have two URLs:
    * http://www.mysite.com/news/ - the news
    * http://www.mysite.com/news/archive - the news archive.

    What happens is this:
    * When you visit news/archive, it uses the archive action to visit the news page
    * This means that the archive() method gets called on the controller object.
    * Since it returns an array, this is interpreted as being changes to the controller data. In this case, we've provided new data for <% control Children %>

    You can also, if you want, make a new template called (classname)_archive.ss

  • redking
    43 Posts

    Re: Archive the news? Link to this post

    Hi Sam,

    I'm trying to achieve the same thing.
    Do those two methods need to be placed in the in the ArticleHolder class?
    I copy/pasted them in there, but I'm having a hard time getting it to work.
    Also, how do I specify only displaying the five most recent articles?


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.