[opencms-dev] get item count with contentloop

Mario Jäger m.jaeger at alkacon.com
Thu Jan 27 16:58:35 CET 2011


Hi,

To get the number of items in a list using EL, you can use the JSTL 
function "length": 
http://download.oracle.com/docs/cd/E17802_01/products/products/jsp/jstl/1.1/docs/tlddocs/fn/length.fn.html

This function returns the number of items in a collection, or the number 
of characters in a string.

In the following example the number of the nodes "Channel" in a xml 
content is given out:
...
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
...
<cms:contentload collector="singleFile" param="<path to the file>">
   <cms:contentaccess var="content" scope="page" />
   ...

   // get the number of the items "Channel"
   <c:set var="count" value="${fn:length(content.valueList.Channel)}" />
   count: <c:out value="${count}" />

   ...
</cms:contentload>

-- 
Kind Regards,
Mario.

-------------------
Mario Jäger

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

Am 21.01.2011 13:35, schrieb eelboy at aol.com:
> Thank you for the suggestion.  I had tried that, but if I place
> cms:contentinfo inside of a cms:contentloop I get an exception:
>
> org.opencms.jsp.CmsJspTagContentLoop cannot be cast to
> org.opencms.jsp.CmsJspTagContentLoad
>
>
> thanks,
> eelboy
>
> On 1/21/2011 5:07 AM, Robert Spielmann wrote:
>> you might try the cms:contentinfo tag. It should give you information
>> about the resultSize etc.
>
> _______________________________________________
> 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