Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Limit a loop??

LEGEND ,
Mar 12, 2008 Mar 12, 2008
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???


257
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2008 Mar 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/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 12, 2008 Mar 12, 2008
LATEST
Listlen() will get you started.

From and to attributes in your cfloop tag will come in handy.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources