Skip to main content
Inspiring
March 12, 2008
Question

Limit a loop??

  • March 12, 2008
  • 2 replies
  • 282 views
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 has been closed for replies.

    2 replies

    Inspiring
    March 12, 2008
    Listlen() will get you started.

    From and to attributes in your cfloop tag will come in handy.
    Inspiring
    March 12, 2008
    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/