CGCalendar display single day - today!

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
rightwebdev
Forum Members
Forum Members
Posts: 15
Joined: Thu Feb 04, 2010 11:19 am

CGCalendar display single day - today!

Post 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?
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: CGCalendar display single day - today!

Post by jmcgin51 »

looks like a good feature request

could be implemented like {cms_module module='CGCalendar' display='list' today='true'}
Peciura

Re: CGCalendar display single day - today!

Post 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'}
Yvan B
Forum Members
Forum Members
Posts: 60
Joined: Thu Apr 08, 2010 3:27 pm

Re: CGCalendar display single day - today!

Post 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)
rightwebdev
Forum Members
Forum Members
Posts: 15
Joined: Thu Feb 04, 2010 11:19 am

Re: CGCalendar display single day - today!

Post 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...
Peciura

Re: CGCalendar display single day - today!

Post 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.
Last edited by Peciura on Fri Apr 23, 2010 6:59 am, edited 1 time in total.
rightwebdev
Forum Members
Forum Members
Posts: 15
Joined: Thu Feb 04, 2010 11:19 am

Re: CGCalendar display single day - today!

Post 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.
Peciura

Re: CGCalendar display single day - today!

Post 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'}
Last edited by Peciura on Fri Apr 23, 2010 9:37 am, edited 1 time in total.
rightwebdev
Forum Members
Forum Members
Posts: 15
Joined: Thu Feb 04, 2010 11:19 am

Re: CGCalendar display single day - today!

Post by rightwebdev »

This looks splendid :) Will try it out later tonight.
User avatar
Franck
Dev Team Member
Dev Team Member
Posts: 261
Joined: Tue Jun 12, 2007 1:29 pm

Re: CGCalendar display single day - today!

Post 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.
Peciura

Re: CGCalendar display single day - today!

Post 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}
User avatar
Franck
Dev Team Member
Dev Team Member
Posts: 261
Joined: Tue Jun 12, 2007 1:29 pm

Re: CGCalendar display single day - today!

Post by Franck »

thanx a lot, I'll try it and let you know.
Last edited by Franck on Mon Nov 08, 2010 11:03 am, edited 1 time in total.
User avatar
Franck
Dev Team Member
Dev Team Member
Posts: 261
Joined: Tue Jun 12, 2007 1:29 pm

Re: CGCalendar display single day - today!

Post 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.
Peciura

Re: CGCalendar display single day - today!

Post by Peciura »

Paste this before {CGCalendar} to see date passed to module

Code: Select all

{'c'|date:$cgcal_unixtimestamp}
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.
User avatar
Franck
Dev Team Member
Dev Team Member
Posts: 261
Joined: Tue Jun 12, 2007 1:29 pm

Re: CGCalendar display single day - today!

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

Return to “Modules/Add-Ons”