I am trying to display some text and relevant information from my Events Collection based on todays date.
I started by writing a system varible in templates/pages/events/detail.php.
-
- PerchSystem::set_var('today', date('Y-m-d'));
-
- perch_collection('Events', [
- 'template' => 'events/event/_enter.html',
- ]);
<perch:showall> confirms that today is avaible for use.
My Events Collection is quite verbose due to each event having three pricing levels, Early Rate, Reduced Rate and Standard Rate.
I would like to take the closing day date for the relevant price level, see whether that date is in the past or future, and display the relevant pricing level text.
I am having issues getting my conditional to display the correct text. Currently it displays the first two if statements, when I was expecting the third.
- <perch:if id="events_price_indv_er_cl" match="lte" value="{today}">
- <p>Early bird entires currently open. From £<perch:content id="events_price_indv_er">.</p>
- <p>Reduced price increase coming <perch:content id="events_price_indv_er_cl" type="date" format="jS M">. £<perch:content id="events_price_indv_rr"></p>
- </perch:if>
- <perch:if id="events_price_indv_rr_cl" match="lte" value="{today}">
- <p>Reduced price entires currently open. From £<perch:content id="events_price_indv_rr">.</p>
- <p>Standard price increase coming <perch:content id="events_price_indv_rr_cl" type="date" format="jS M">. £<perch:content id="events_price_indv_sr"></p>
- </perch:if>
- <perch:if id="events_price_indv_sr_cl" match="lte" value="{today}">
- <p>Standard entires currently open. From £<perch:content id="events_price_indv_sr">.</p>
- <p>Entires closing <perch:content id="events_price_indv_sr_cl" type="date" format="jS M"></p>
- </perch:if>
Display More
events_price_indv_er_cl => 31/10/2019
events_price_indv_rr_cl => 04/01/2020
events_price_indv_sr_cl => 30/08/2020
The way understand the to work is, if date is less than or equal to today's date display the content.
I'd appreciate some guidance on the conditional as I am clearly not understanding this fully.