[opencms-dev] two questions about cms:contentload

Claus Priisholm cpr at codedroids.com
Mon Jul 25 15:21:13 CEST 2005


Just been struggling with the same issue as your item 1...

Felix Garcia wrote:
> Hi Everybody,
> 
> 
> 1) Before listing xml content resources with <cms:contentload 
> collector=..., how can I check if there is at least one element before 
> executing or not contentload loop?
> 

There seem to be a problem with the contentload-tag implementation. It 
will always execute the contents at least once, even if there are no items.
It will then either throw an exception or (and that is much more 
confusing) simply use the last item of any previous listing of content 
with the same type (I have three separate lists, one of which is 
currently empty, but the last item from the either of the two non-empty 
list will show up in the empty list if one of them was display 
previously.) I'll post it to bugzilla if it is not already there.

Luckily the actual collector returns the correct result so you can do 
something along these lines:

<%@page import="java.util.*, org.opencms.file.*, 
org.opencms.file.collectors.*, org.opencms.main.*, ..." %>
<%
   CmsJspActionElement cms = new CmsJspActionElement(pageContext, 
request, response);

   String collName = "allInSubTreeDateReleaseDesc";
   I_CmsResourceCollector coll = 
OpenCms.getResourceManager().getContentCollector(collName);
   List list = coll.getResults(cms.getCmsObject(), collName, 
"/some/path/|some_type" );

   if(list != null && list.size() > 0) {
%>
... the usual cms:contentload stuff ...
<%
   }
%>

> 2) Inside cms:contentload I can check if a element exists but, How can I 
> check if an element doesn't exist?
> 
> Regards
> 
> 
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
> 

-- 
Claus Priisholm, CodeDroids ApS
cpr (you know what) codedroids.com - http://www.codedroids.com

Javadocs and other OpenCms stuff: 
http://www.codedroids.com/community/opencms



More information about the opencms-dev mailing list