Page 1 of 1

Calendar: Check if there is no event in a month

Posted: Tue Jul 25, 2017 1:53 pm
by steven_germany
Hello,

in a brand new cms installation with updated moduls
i want to check in the calendar if there is no event in
the month. I use the list-template

Just to display the user: "No Events in this month" (or something like that)

Any idea?

Regrads

Stefan

Re: Calendar: Check if there is no event in a month

Posted: Wed Jul 26, 2017 7:52 am
by velden
Usually those templates have some kind of array which they iterate to show the items ( {foreach...} )

Read about the foreachelse method
https://www.smarty.net/docs/en/language ... oreach.tpl

This would be useful if you want to show the events if there are any and else show the 'no events' message.

If you just want to check for the non-existence of events then just check the length of the array.

Re: Calendar: Check if there is no event in a month

Posted: Wed Jul 26, 2017 11:26 am
by steven_germany
Velden,

thank you so much!!!! It works :-)

Kind regards
Stefan

Re: Calendar: Check if there is no event in a month

Posted: Tue Aug 15, 2017 4:37 pm
by CapereSpiritum
Hi Steven
I would be very grateful to learn how you did it.
Would you be so kind as to display the {foreach} and any subsequent {if} statement?

Many thanks
Simon

Re: Calendar: Check if there is no event in a month

Posted: Thu Aug 17, 2017 8:02 am
by steven_germany
Hi Simon,

it is very simple :-)


{foreach from=$events key=key item=event}

HERE WRITE ALL THE THINGS FOR DISPLAYING YOUR CALENDAR THINGS

{foreachelse}

HERE WRITE WHAT SHOULD HAPPEN WHEN THERE IS NO ENTRY

{/foreach}