Page 1 of 2
CGCalendar display single day - today!
Posted: Thu Apr 22, 2010 11:06 am
by rightwebdev
I'm looking for a way to display the current day with all its events. Is there support for such a function or will I need to digg into the code files again?
Re: CGCalendar display single day - today!
Posted: Thu Apr 22, 2010 1:13 pm
by jmcgin51
looks like a good feature request
could be implemented like {cms_module module='CGCalendar' display='list' today='true'}
Re: CGCalendar display single day - today!
Posted: Thu Apr 22, 2010 3:21 pm
by Peciura
Create new CGCalendar template and instead of looping all over the month show one day only.
Let say you created calendar template 'one_day' that looks like this
Code: Select all
{assign var='current_day' value='d'|date}
{$days[$current_day].events|debug_display}
Call it
Code: Select all
{cms_module module="CGCalendar" display='calendar' calendartemplate='one_day'}
Re: CGCalendar display single day - today!
Posted: Thu Apr 22, 2010 3:54 pm
by Yvan B
Thanks ! This may be useful.
Btw, I've just installed the 1.5.2 version and I was wondering why, when I've not defined the day (only the month and the year), the value of {$day} is "Array" ? In the event list, the first line is 'Array April 2010'. (I'm using the french version)
Re: CGCalendar display single day - today!
Posted: Thu Apr 22, 2010 4:45 pm
by rightwebdev
Peciura wrote:
Create new CGCalendar template and instead of looping all over the month show one day only.
Let say you created calendar template 'one_day' that looks like this
Code: Select all
{assign var='current_day' value='d'|date}
{$days[$current_day].events|debug_display}
Call it
Code: Select all
{cms_module module="CGCalendar" display='calendar' calendartemplate='one_day'}
There's one problem with it. It does not display the name of the day...
Re: CGCalendar display single day - today!
Posted: Thu Apr 22, 2010 6:17 pm
by Peciura
the value of {$day} is "Array"
In short you are trying to use array as a string that is why it outputs "Array". You should access array members instead. You can see how to access member by its
number and by
key and ask
more info about variable (possibly array too

)
{$days[$current_day].events|debug_display}
Knowing that it should be easy to inspect variable you want.
@rightwebdev it was exact answer to question. But if you post your template and link to page i am sure we could build smth more appealing.
Re: CGCalendar display single day - today!
Posted: Fri Apr 23, 2010 5:12 am
by rightwebdev
http://web1.lunarum.com/index.php?page=diary This is the main calendar. Now I would like to show the current day with name, date and all the events in the upper right hand corner. I think this can _almost_ be done with css alone. Hide all the days except the current day. But the same problem occurs - no way to add the name of the day.
Re: CGCalendar display single day - today!
Posted: Fri Apr 23, 2010 8:48 am
by Peciura
EDIT :
I noticed there is one
undocumented parameter "day" in CGCalendar 1.5.2. Just call it like this and you will have events of current day only
{cms_module module='CGCalendar' display='list' day='d'|date}
If you need name of week day - add this smarty code to CGCalendar list template
{assign var='weekday' value='N'|date}
{assign var='weekday' value="`$weekday-1`"}
{$day_names[$weekday]} {*name of week day*}
/*---------------------------- left just because it was first suggestion ------------------------*/
It is also basic i am sure you will style it the way you want. CGCalendar calendar template 'one_day'
Code: Select all
{assign var='current_day' value='d'|date}
{assign var='weekday' value='N'|date}
{assign var='weekday' value="`$weekday-1`"}
{strip}
{$day_names[$weekday]} {$current_day} {$month_names[$month]} {$year}<br/>
{assign var='day' value=$days[$current_day]}
{if !empty($day.events)}
<div {if isset($day.class)}class="{$day.class}"{/if}>
<ul>
{foreach from=$day.events item=event}
<li><a href="{$event.url}">{$event.event_title}</a></li>
{/foreach}
</ul>
</div>
{else}
No events
{/if}
{/strip}
To display one day - specify template
Code: Select all
{cms_module module='CGCalendar' display='calendar' calendartemplate='one_day'}
Re: CGCalendar display single day - today!
Posted: Fri Apr 23, 2010 12:33 pm
by rightwebdev
This looks splendid

Will try it out later tonight.
Re: CGCalendar display single day - today!
Posted: Wed Nov 03, 2010 12:28 am
by Franck
Hello,
I use the cgcalendar module to display a restaurant menu. On the homepage, I'm using the "day" parameter to show the current day menu, it's working like a charm.
But. I have another problem / request : I need to display on another page the current week menus= 5+2 events, the last 2 are for the weekend and display the same information. The thing is how do I set the current week? I know it's with smarty tags, but can't figure out how to do it.
Thanx for your help.
Re: CGCalendar display single day - today!
Posted: Thu Nov 04, 2010 4:54 pm
by Peciura
First of all you need to now current week start time and then call CGCalendar foreach day (that is 7 times in you case).
Here is basic template to list events for current week. Do not forget to use appropriate list template.
Code: Select all
{if 1!='%w'|strftime}
{assign var='date_string' value='last monday'}
{else}
{assign var='date_string' value=''}
{/if}
{section start='0' loop='7' name='current_week'}
<br/>
{assign var='cgcal_unixtimestamp' value=$date_string|cat:' + %s day'|sprintf:$smarty.section.current_week.index|strtotime}
{CGCalendar display='list' year='Y'|date:$cgcal_unixtimestamp month='m'|date:$cgcal_unixtimestamp day='d'|date:$cgcal_unixtimestamp listtemplate='list'}
{/section}
Re: CGCalendar display single day - today!
Posted: Thu Nov 04, 2010 7:47 pm
by Franck
thanx a lot, I'll try it and let you know.
Re: CGCalendar display single day - today!
Posted: Mon Nov 08, 2010 9:40 pm
by Franck
It's working perfectly, your help is highly appreciated!
I have a weird thing with the 'day' parameter: it's the day+1 event that's displayed instead of day. Do you have any clue about what could be wrong? I first thought of a timezone, but my server seems to be configured ok.
Re: CGCalendar display single day - today!
Posted: Tue Nov 09, 2010 2:08 am
by Peciura
Paste this before {CGCalendar} to see date passed to module
I guess smth weird is in your list template.
What is your time zone (mine +2 ) and locale (mine lt_LT.UTF-8) ?
If nothing works you could simply do
{CGCalendar display='list' year='Y'|date:$cgcal_unixtimestamp month='m'|date:$cgcal_unixtimestamp day='d'|date:$cgcal_unixtimestamp-1 }
but i consider it as debugging step only.
Re: CGCalendar display single day - today!
Posted: Tue Nov 09, 2010 8:09 pm
by Franck
it's really weird in fact: I can't really tell how it's displaying, as yesterday shows the news for today, and today also the one for today. Well... ?
Oh a detail that might be important: I'm using the eventtemplate and display='event'.
By the way, thanx a lot for your help!