Hi, I'm trying to set my upcoming events list to show a default message if there are no events to list. I tried to make a modified version of Elijah Lofgren's count_news_items user defined tag, but I pretty much botched it up. Has anyone had success doing this? Any help is greatly appreciated. Thanks!
Using CMSMS 1.4 Jamaica
Calendar 0.8.2
If no events to list, show a default message
Re: If no events to list, show a default message
I was looking for this too and couldn't find the answer on the forum, so I did some digging in the code. It turns out that probably the easiest solution is using smarty {foreachelse} clause. In your CMS admin area go to Calendar and switch to the template tab you are working with (list or upcoming). In the code find {/foreach} then add {foreachelse} with your message code right berfore it. Your template should have the structure as follows:
{foreach from=$events key=key item=event}
... bunch event listing code ...
{foreachelse}
no events ...or the other message of your choice
{/foreach}
According to smarty website: {foreachelse} is executed when there are no values in the from variable.
Best regards
{foreach from=$events key=key item=event}
... bunch event listing code ...
{foreachelse}
no events ...or the other message of your choice
{/foreach}
According to smarty website: {foreachelse} is executed when there are no values in the from variable.
Best regards
Re: If no events to list, show a default message
You rock! Thanks so much for your reply! I'm going to try it out now!
[SOLVED] If no events to list, show a default message
Hurrah! It worked! Thanks so much! I knew I needed a snippet of code, but I just kept getting it wrong. You might consider posting this to the Tips & Tricks section?