[opencms-dev] Problem with contentload

Robert Petermeier robert2.0 at gmx.de
Mon Oct 24 16:42:44 CEST 2005


Matthias Neher schrieb:
> Hi list,
> 
> I'm still working at my news-archive.
> To remember: I have news items which are xml content files. These files are
> stored in a folder called news.

[... news + archive ...]

> My second approach is to have no special archive folder. All news (actual
> ones and old ones) are in the same folder. 

I had to do exactly the same in a project. What I did is the following:
- Have all the news in one folder
- Write a JavaBean which uses the API of OpenCms to retrieve a
Collection of either all non-expired or all expired resources of type
'news' in a folder
- Provide some methods to access the fields of XML-content files of type
'news', like headline, body, image or whatever

You have to dig into the XML-content packages of OpenCms. I used this
approach because I had to work with an older development version of 6.0.
The taglib in that version could not reliably retrieve expired
resources. I don't know why, sometimes it worked, sometimes it didn't. I
presume that this has been fixed by now.

If that is the case, a much easier solution is to implement your own
resource collector which collects only expired resources and switch
between this one and a standard one which ignores expired items in a
template or JSP. For non-expired news you use:

<cms:contentload collector="allInFolderDateReleasedDesc" ...>
    ....
</cms:contentload>


And to collect expired news you use:
<cms:contentload collector="expiredOnlyDateReleasedDesc" ...>
    ....
</cms:contentload>

Just search the archive for resource collector.


Bye,
Robert





More information about the opencms-dev mailing list