Page 1 of 1

[SOLVED] CGCalendar: checking if events exist at all

Posted: Tue Jun 03, 2014 1:12 pm
by Guido
Hi,

I've been wrapping my head around this and googling for a while, but I can't seem to find the answer (while I think it should be quite simple).

I have a page where in the sidebar I call the upcoming events of the CGCalendar module. The thing is, sometimes the calendar will hold no upcoming events. In that case I would like to hide the calendar block.

I tried modifying my upcoming events template like:

Code: Select all

{if isset($events)}
{assign var="present" value="yes"}
{else}
{assign var="present" value="no"
{/if}
In the top of the template. In the page template I would then check the "present" value to decide whether to show the calendar block or not.

But it seems that when no upcoming events are present, the upcoming events template is never even called, so the value for "present" is never set.

Now I'm trying to figure out how to check from my page template if the CGCalendar $events array is set, but I'm striking out. Anyone have any ideas?

Re: CGCalendar: checking if events exist at all

Posted: Tue Jun 03, 2014 1:28 pm
by uniqu3
You could assign CGCalendar module tag with upcomminglist to a smarty variable and do your logic in page template

Code: Select all

{CGCalendar display='upcominglist' assign='upcoming_list'}
{if !empty($upcoming_list)}
{$upcoming_list}
{/if}

Re: CGCalendar: checking if events exist at all

Posted: Tue Jun 03, 2014 1:38 pm
by Guido
Dude, you saved my life again. Knew it had relatively easy but I couldn't figure it out.

Thanks!