Forum

Thread tagged as: Question, Configuration, Events

Perch Events conditional call

So I'm still new to Perch and this may be quite easy, but I am lost and would appreciate any help. Right now I have an Events app list calendar that shows a few months at the same time. I've used this code:

<?php

                  $_GET['d']  = date('Y-m');
                  perch_events_listing();

                  $_GET['d']  = date('Y-m', strtotime('+1 MONTH'));
                  perch_events_listing();

                  $_GET['d']  = date('Y-m', strtotime('+2 MONTH'));
                  perch_events_listing();

                      $_GET['d']  = date('Y-m', strtotime('+3 MONTH'));
                  perch_events_listing();

              ?>

What I want is to have 3 months show up, but on the condition that there are events in those months. So, a month that has no events in it would be ignored and not display on the site.

Can someone help me set this up? Please and thank you.

Lindsay Masten

Lindsay Masten 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to test the results you get back and keep going until you have enough. You'll need to be careful not to let it run away if no events have been scheduled.

I apologize for being so new at this, but can you give me an example of how I might set it up to test? I really don't even know how to start. Do I edit the files inside the Events app, or do I edit the code to reference the app (what's above)?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'm not sure how you'd do it, to be honest. The app doesn't have what you're after built in, so it's going to be a case of trying to make the most of the functionality that is there and turning it to your needs.

Ah, thanks. I may be in over my head but I'll experiment and if there's any success I'll report back.