If no events to list, show a default message

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
marisafal
Forum Members
Forum Members
Posts: 29
Joined: Thu Mar 20, 2008 9:04 pm

If no events to list, show a default message

Post by marisafal »

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
cnisvcs
Forum Members
Forum Members
Posts: 37
Joined: Wed Jan 30, 2008 3:02 am

Re: If no events to list, show a default message

Post by cnisvcs »

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
marisafal
Forum Members
Forum Members
Posts: 29
Joined: Thu Mar 20, 2008 9:04 pm

Re: If no events to list, show a default message

Post by marisafal »

You rock! Thanks so much for your reply! I'm going to try it out now!
marisafal
Forum Members
Forum Members
Posts: 29
Joined: Thu Mar 20, 2008 9:04 pm

[SOLVED] If no events to list, show a default message

Post by marisafal »

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?
Post Reply

Return to “Modules/Add-Ons”