[opencms-dev] get item count with contentloop

eelboy at aol.com eelboy at aol.com
Thu Jan 27 17:45:44 CET 2011


Thanks Mario!  If I had only known about the cms:contentaccess tag -- 
for some reason that one doesn't show up in the documentation module.    
But it's jut what I needed.
Regards,
eelboy

On 1/27/2011 10:58 AM, Mario Jäger wrote:
> 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>
>



More information about the opencms-dev mailing list