[SOLVED] CGCalendar: Display text when no upcoming events

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Hypocrite
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 26, 2009 6:25 am

[SOLVED] CGCalendar: Display text when no upcoming events

Post by Hypocrite »

I am using the following code to display upcoming events in CGCalendar:

Code: Select all

<div class="cal-upcominglist">

{foreach from=$events key=key item=event}
	<div class="calendar-event">
	<h4><a href="{$event.url}">{$event.event_title}</a></h4>

	{assign var=month_number value=$event.event_date_start|date_format:"%b"}
	{assign var=end_month_number value=$event.event_date_end|date_format:"%b"}
	{if $event.event_date_start == $event.event_date_end || $event.event_date_end == 0}
	<div class="calendar-date-from"><span class="calendar-date-title">Koulutus alkaa: </span>{$event.event_date_start|date_format:"%e"}. {$event.event_date_start|date_format:"%b"} {$event.event_date_start|date_format:"%Y"}</div>
	{else}
	{if $event.event_date_start|date_format:"%d%m%Y" == $event.event_date_end|date_format:"%d%m%Y"}
	<div class="calendar-date-from"><span class="calendar-date-title">Koulutus alkaa: </span>{$event.event_date_start|date_format:"%e"}.  {$event.event_date_start|date_format:"%b"} {$event.event_date_start|date_format:"%Y"}</div>
	{else}
	<div class="calendar-date-from"><span class="calendar-date-title">Koulutus alkaa: </span>{$event.event_date_start|date_format:"%e"}. {$event.event_date_start|date_format:"%b"} {$event.event_date_start|date_format:"%Y"} {$lang.to} {$event.event_date_end|date_format:"%e"}. {$event.event_date_start|date_format:"%b"} {$event.event_date_end|date_format:"%Y"}</div>
	{/if}
	{/if}
	
	</div>
        <br />
{/foreach}

{if $return_url != ""}
<div class="calendar-returnlink"><a href="javascript:history.go(-1)"> Go back</a></div>
{/if}
</div>
How could I modify this so that it would show a text when there are no upcoming events?

I am using CMS Made Simple 1.9.2 and CGCalendar 1.5.6.
Last edited by Hypocrite on Fri Jan 28, 2011 2:07 pm, edited 1 time in total.
User avatar
M@rtijn
Power Poster
Power Poster
Posts: 706
Joined: Sat Nov 14, 2009 4:54 pm

Re: CGCalendar: Display text when there are no upcoming even

Post by M@rtijn »

I guess this will do the trick

Code: Select all

<div class="cal-upcominglist">

{if !isset($event)}no data{/if}

{foreach from=$events key=key item=event}
... rest of your code
Make your community a better place!
Hypocrite
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 26, 2009 6:25 am

Re: CGCalendar: Display text when there are no upcoming even

Post by Hypocrite »

Hmm, doesn't seem to be display correctly.

I have several callbacks in one page for different categories like this:

Code: Select all

<h3>Category 1</h3>

{cms_module module='CGCalendar' display='upcominglist' calendartemplate='raiku' use_session='46451' detailpage='calendar' category='Category 1'}

<h3>Category 2</h3>

{cms_module module='CGCalendar' display='upcominglist' calendartemplate='raiku' use_session='46451' detailpage='calendar' category='Category 2'}

<h3>Category 3</h3>

{cms_module module='CGCalendar' display='upcominglist' calendartemplate='raiku' use_session='46451' detailpage='calendar' category='Category 3'}
When I used your code it showed the text in the first category even though there were upcoming events but didn't display it in the second one where there were no upcoming events.
User avatar
M@rtijn
Power Poster
Power Poster
Posts: 706
Joined: Sat Nov 14, 2009 4:54 pm

Re: CGCalendar: Display text when there are no upcoming even

Post by M@rtijn »

Ahh, bit more difficult then I thaught. :-\

I use the {if !isset($event)}no data{/if} for a pastlist, where it works fine. It seems upcominglist behaves different.

The if statement in the template checks if there are events. If not, it shows 'no data'
In pastlist the template is passed with or without events present. Within the template you can use this statement.

It seems upcominglist checks if events exist, if case is 'yes' it passes the template, if the case is 'no' it does nothing. That's why the statement is not working for the categories which are empty.

I've tried to find another solution, but I can't help you out, sorry ::)
Make your community a better place!
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: CGCalendar: Display text when there are no upcoming even

Post by psy »

This works for me. In the actual page, not the upcoming events template, put:

{capture assign=upcomers}{cms_module module=CGCalendar category=Seminars display=upcominglist}{/capture} {if isset($upcomers) and $upcomers ne null}{$upcomers}{else}
Upcoming Events
There are no events scheduled.
{/if}

hth
psy
Hypocrite
Forum Members
Forum Members
Posts: 48
Joined: Wed Aug 26, 2009 6:25 am

Re: CGCalendar: Display text when there are no upcoming even

Post by Hypocrite »

Thanks!

That worked like a charm.
Post Reply

Return to “Modules/Add-Ons”