Skip to main content
Inspiring
Mar 12, 2008 10:52 PM UTC
Question

Limit a loop??

Is there a way to limit how many items are displayed in a loop (list loop)??

I am thinking of a way I can check if there are more than 3 items in a list,
if there are, display the 3 items in the first area, and then display the
remining items in a 2nd area....

Anyone done anything like this? Suggestions???


    This topic is closed to new replies. Start a new post to keep the conversation going.

    2 replies

    Inspiring
    Mar 12, 2008 11:22 PM UTC
    Listlen() will get you started.

    From and to attributes in your cfloop tag will come in handy.
    Translate
    Inspiring
    Mar 12, 2008 11:00 PM UTC
    something like this?:

    <cfloop from="1" to="3" index="iii">
    #listgetat(mylist, iii)#
    </cfloop>
    <cfif listlen(mylist) gt 3>
    <cfloop from="4" to="#listlen(mylist)#" index="iii">
    #listgetat(mylist, iii)#
    </cfloop>
    </cfif>

    not sure if you want a new area for every 3 list items or just first 3
    in first area and the rest of list (no matter ho long) in the second
    area... my code is for the first case. mind you: from memory and not
    tested...

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Translate