Forum

Thread tagged as: Question, Problem, Events

How do I display a recurring time-period-based Event within this time period?

Hi folks,

sorry if the question seems a bit odd, but i got the following case and dont really no how to do this best:

My client got a restaurant witch got a saison-based menu. So if it is tomato-saison, there will be al lot of tomato stuff on the menu, in the christmas time a lot of duck-stuff and so on. This time periods are mostly fixed and doesn't change over the years (mostly).

So what i want to is to auto-display a small message "hey we got some tomatos" in the tomato-saison, etc.

I first tought about the event-app (problem with the recurring events?) than about a simple if-statement (dont get how to filter the time period).

Got anyone a idea?

Thanks for your help!

Manuel Hügel

Manuel Hügel 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

So you want to specify two dates and a message to display between them?

Long story short, yes!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Create a region with your messages (e.g. Messages).

In the template, add a field for the message, one for the start date and one for the end date.

<perch:content id="message" type="textarea" markdown="true" editor="markitup" label="message" required="true" />
<perch:content id="start_date" type="date" label="Start date" suppress="true" />
<perch:content id="end_date" type="date" label="Start date" suppress="true" />

Then display your message based on the date:

perch_content_custom('Messages', array(
     'filter' => array(
        array(
            'filter' => 'start_date',
            'match' => 'gte',
            'value' => date('Y-m-d'),
        ),
        array(
            'filter' => 'end_date',
            'match' => 'lte',
            'value' => date('Y-m-d'),
        ),
     ),
     count => 1,
));

Lots of thanks! :)