Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Event Calendar (Live Calendar) Starting from Monday


Go to End


5 Posts   2245 Views

Avatar
BP

Community Member, 25 Posts

4 October 2011 at 11:00am

Edited: 10/10/2011 10:14am

Hi all, hi Uncle Cheese ,

Very happy with the Event Calendar module , however stuck on localization. I need Live Calendar Widget to display week starting from Monday rather then Sunday. Is there any solution for that ?

I'm using the version from SVN, not sure which version is that, but rather new one :)

Thanks in advance

UPD: Chatting on IRC i realised that non of the guys there knew what is LiveCalendarWidget :) . So just to let you know it comes with event_calendar, and you DONT NEED TO INSTALL ANY WIDGETS :). You can simply call it on a template with $LiveCalendarWidget and it's cool :)

Avatar
BP

Community Member, 25 Posts

10 October 2011 at 10:08am

Uncle Cheese - I'm still hoping you will give a proper answer for that :)

For now -for all those NON-USA people who are desperately looking for solution a Wild and Crazy hotfix :

in CalendarUI.class.php
in getWeeks function :

First generated week would have 8 days instead of 7
so in the first FOR cycle (where we iterate $i for weeks do something like :

  $limit=7;
  if($i==0){$limit=8;}

in second FOR cycle , which loop $j for week days chachge number 7 to $limit

for($j=0; $j < $limit; $j++)

So the only problem now - you've got 8 days in the first week so we have to skip it when it comes to
$days->push(new ArrayData(array(...
So we only push the day if its not the first day of the first week with ($i+$j>0)

And the job is done !

Now the only thing is to change LiveCalendarWidget.SS and replace $Sun with $Mon and $Mon with $Sun .

Works fine :) If UC will provide another solution, I would be more than happy to use it :)

Just so everyone could just copy-paste - here the whole getWeeks function from CalendarUI.class.php (around 184 line)

protected function getWeeks()
  {
    $weeks = new DataObjectSet();
    $today = new sfDate();
    $today->clearTime();
    $this->date_counter->firstDayOfMonth()->firstDayOfWeek();
    $view_start = new sfDate($this->date_counter->get());
    $view_end = new sfDate($view_start->addDay($this->rows*7)->subtractDay()->get());
    $view_start->reset();
    $this->start_date->reset();
    $event_map = $this->getEventsFor($view_start, $view_end);
    
 		for($i=0; $i < $this->rows; $i++)
		{
		  
		  $days = new DataObjectSet();
		  $week_range_start = $this->date_counter->format('Ymd');

		  $limit=7;
		  if($i==0){$limit=8;}
		  
			for($j=0; $j < $limit; $j++)
			{
				$current_day = "";
				if(!$this->default_view) {
				  if( ($this->date_counter->get() >= $this->anchor_start->get()) && ($this->date_counter->get() <= $this->anchor_end->get()) )
				    $current_day = "currentDay";
        }		
			  if($i+$j>0)
			  {
				$days->push(new ArrayData(array(
				  'Today'           => $this->date_counter->get() == $today->get() ? "calendarToday" : "",
				  'OutOfMonth'      => $this->date_counter->format('m') != $this->start_date->format('m') ? "calendarOutOfMonth" : "",
				  'CurrentDay'      => $current_day,
				  'HasEvent'        => in_array($this->date_counter->date(), $event_map) ? "hasEvent" : "",
				  'Events'          => $this->calendar->Events(null, $this->date_counter->date(), $this->date_counter->date()), 				  
				  'ShowDayLink' => $this->calendar->Link('view')."/".$this->date_counter->format('Ymd'),
				  'Number'          => $this->date_counter->format('d')
				)));
			  }

				$this->date_counter->addDay();
			
			}
			
			$week_range_end = $this->date_counter->subtractDay()->format('Ymd');
			$this->date_counter->addDay();
			
			 
			 
			
			 
			$weeks->push(new ArrayData(array(
			 'Days' => $days,
			 'ShowWeekLink' => $this->calendar->Link('view')."/".$week_range_start."/".$week_range_end
			)));
		}
		
		
		
		
		
		return $weeks;  
  }

Avatar
redactuk

Community Member, 117 Posts

15 October 2011 at 12:37am

Edited: 15/10/2011 12:38am

I think my dirty solution was in CalendarUI.class.php I changed:

$view_start = new sfDate($this->date_counter->get());

to

$view_start = new sfDate($this->date_counter->addDay()->get()); 

Avatar
UncleCheese

Forum Moderator, 4102 Posts

16 October 2011 at 5:29am

Awesome patch! Thank you. I'll wrap some conditionals around it so that we can make this a configurable option.

v---------------
Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

Avatar
wilsonStaff

Community Member, 143 Posts

17 October 2011 at 5:52am

Unclecheese, first thanks for contributing.

I am a novice at SS and nowhere a phd in PHP!!!! :-)

I am trying to implement a calendar into my Page.ss template. I cant seem to do it.

I use:
event_calendar
dateobject_manager
along
multiform
all under SS 2.4.5

I can:
- create calendar pages
- create event_calendar pages

But when i click on DRAFT, i only see Page.ss template but, oddly, with the title of the Calendar Page.

HOW DO I INSERT THE CALENDAR into my Page.ss template?

I cant even see the calendar.

Thanks!