I installed this for a client - and now they're asking for a way to archive their news. Any way to do that?
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.
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
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?
Thanks!