Testing against *all* items within a repeater

  • Hi there,


    I am building a site for a company that gives small group tours. The tours have a handful of scheduled dates per year, and the user can also request a custom/desired date. If there are no scheduled dates, it falls back on just allowing the user to request the desired date.


    This is currently working just fine:


    1. Admin enters a date via a repeater; dates display in a list, and an extra list item is added that mentions the ability to request a custom date (Custom date message #1)

    2. If there are no dates in the repeater, a message displays re: requesting a custom date; however it is a different message than the one above (Custom date message #2)


    Here's a simplified version of how the page spits this out:


    This is fine. The next step is to automatically filter out any dates whose departure_date has passed.


    No problem here – I have a variable set up that I am testing against within the repeater:

    This allows the admin to not have to manually remove dates for tours that are in the past. Great!

    Now the actual question:

    Is it possible to run a similar check against ALL items within a repeater?


    With the second code block above, if ALL of the dates in the repeater are in the past, the "Custom date message #1" will still appear, since the initial perch:if that checks for the existence of scheduled_dates will still be true.


    What I would rather have is the "Custom date message #2" appear. I know I am being a bit fussy here, but in this particular usage it's all about the wording of these two messages.


    I understand how I could filter out the dates if this was a multiple item region with one item per date, by using perch_content_custom and relying on the <perch:noresults>; but in this case each tour is an item within a multiple item region, hence the usage of the repeater for dates.


    :/ Thanks for any suggestions!

  • drewm

    Approved the thread.
  • Hi Richard,


    I think you'll have to perform the check outside of the template. One option would be to use of the each option:




    HTML
    1. <perch:if exists="all_past">
    2.     <!--* your message *-->
    3. </perch:if>