SV: [opencms-dev] XML-Content selected by date

Stefan Uldum Grinsted stefan at e-nation.dk
Mon Aug 21 16:47:17 CEST 2006


Dave said:
" The main disadvantage is that you must register your collector in the
config file opencms-vfs.xml"

You don't have to. You can du that in you ModuleAction class. This following
snip of code will register YourResourceCollector during startup of OpenCMS
(given that the ModuleAction class is configured for the module)

public class ModuleAction implements I_CmsModuleAction {
	/* snip */

	public void initialize(...) {
		// Add the resource collectors
		try {
	
OpenCms.getResourceManager().addContentCollector(YourResourceCollector.class
.getName(), "0");

		} catch (CmsConfigurationException e) {
			LOG.error("Could not add ResourceCollector", e);
		}
	}
}

Cheers, Stefan

-----Oprindelig meddelelse-----
Fra: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] På vegne af Dave Schoorl
Sendt: 21. august 2006 17:26
Til: The OpenCms mailing list
Emne: Re: [opencms-dev] XML-Content selected by date

You could implement your own collector that will do the selection, so 
only valid documents are returned to CmsJspTagContentLoad. The main 
disadvantage is that you must register your collector in the config file 
opencms-vfs.xml. And this does not get distributed via the module mechanism.

/Dave

Jens Kreutschmann wrote:
> Hello all,
> I am trying to put a news archive on my site. I want the articles older
than
> a given date on an extra page.
> 
> I've been playing around a bit and came up with:
> 
> 
> CmsJspXmlContentBean content = new CmsJspXmlContentBean(pageContext,
> request, response);
> 
> CmsJspTagContentLoad contentlist =
>
(CmsJspTagContentLoad)content.contentload("allInFolderDateReleasedDesc","/de
> /presse/blub_${number}|article",true);
> Calendar ArchivZeit = Calendar.getInstance();
> ArchivZeit.add(Calendar.HOUR,-32);
> String locale = content.property("locale","search");
> 
> Calendar ArtikelZeit = Calendar.getInstance();
> 
> while(contentlist.hasMoreContent()){
>
ArtikelZeit.setTimeInMillis(Long.parseLong(content.contentshow(contentlist
> ,"Release")));
>   if(ArtikelZeit.after(ArchivZeit)){
>
out.print("<div><h3>"+content.contentshow(contentlist,"Title")+"</h3>"
> );
>    out.print("<br
> />"+CmsDateUtil.getDateTime(ArtikelZeit.getTime(),DateFormat.SHORT,new
> Locale(locale)));
>     out.println("</div>");
>   }else{
>     break;
>   }
> }
> 
> 
> 
> This works nearly fine. It works in the online project. However, in the
> offline project it shows me the wanted result plus an unwanted direct edit
> button for the first article which is older than 32 hours(in this case)
> I can imagine, why this is, but i dont know how i can work around this
> problem.
> 
> Would be glad, if i can get any help or hints
> 
> Jens
> 
> 
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev


_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list