ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Counting through loops (if / else)

March 03, 2010 2:35am

Subscribe [1]
  • #1 / Mar 03, 2010 2:35am

    disegno

    3 posts

    Hi,

    Is there a way to have a count (not the native {count}) to count your way through an if loop?

    ie. in the below, I want to show a heading of “Today” IF there are people on leave, AND only the first time it loops through the code.

    I can’t use the native {count} variable, as it could get 5 entries, but only show 2 that fall within the range defined in the if statement.

    Code ref:

    {exp:weblog:entries weblog="staff_leave" orderby="staff_leave_start" sort="asc" disable="categories|category_fields|member_data|pagination|trackbacks"}
        {if ({current_time format="%U"} >= staff_leave_start) AND ({current_time format="%U"} <= staff_leave_end)}
            <strong>Today: {title}</strong>
        {/if}
    {/exp:weblog:entries}

    Regards,

    Christiaan

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases