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.

Archive

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

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

Archive the news?


Reply

3 Posts   1950 Views

Avatar
abelcreative

9 August 2007 at 1:51am 4 Posts

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

Avatar
Sam

9 August 2007 at 3:37pm Administrator, 685 Posts

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

Avatar
redking

14 April 2008 at 9:52am 43 Posts

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!