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.

All other Modules /

Discuss all other Modules here.

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

Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class


Reply


19 Posts   1973 Views

Avatar
TF-35Lightning

Community Member, 137 Posts

10 August 2010 at 9:00pm

Final thing I am having trouble with unclecheese is getting my additional field to show up on the front end $Rollovertext. I have in LiveCalendarWidget.ss

<% control Weeks %>
      <tr>
   <% control Days %>
   <% if HasEvent %>
<td class="$HasEvent">
          <a href="$ShowDayLink">$Number<SPAN>$Rollovertext</SPAN></a>
         </td>
<% else %>
         <td class="$Today $OutOfMonth $CurrentDay">
          <a href="$ShowDayLink">$Number</a>
         </td>
<% end_if %>
<% end_control %>

And in CalendarEvent I have.

public function getCMSFields()
   {
      $f = parent::getCMSFields();
      $dt = _t('CalendarEvent.DATESANDTIMES','Dates and Times');      
            
      $f->addFieldsToTab("Root.Content.$dt", array (
      
         new TextField('Rollovertext', 'Rollovertext'),

//rest of function etc

But when I call $Rollovertext nothing shows up. What else do I need to do?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

11 August 2010 at 3:03am

Yeah, the calendar isn't event-aware in the sense that it can pull events on to the calendar. It's only aware of the binary "HasEvent" yes/no question. If it pulled in the actual events associated with that date, it would create a major scalability problem, since dates can have many events. What rollover text would you show if there were 8 events on the same day?

Avatar
TF-35Lightning

Community Member, 137 Posts

11 August 2010 at 2:00pm

UncleCheese all I wanted to be able to do was for the CMS user to be able to enter a small description of the event and have that popup when they rolledover any of the hasEvents on the LiveCalendarWidget. Say 100 characters (3 lines).

I've got everything else in place, the rollover etc, this is the final thing that I have to do. Can it be done?

Some of the guys of the chatroom said I would have to add to the Day array uner CalendarUI.class.php because that is the control block I am in on the front end trying to call from.

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');
         for($j=0; $j < 7; $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";
}            
            $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" : "",
             '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;
}

Let us know what you think.

Avatar
UncleCheese

Forum Moderator, 4096 Posts

12 August 2010 at 1:40am

But again, you're thinking of dates and events as one-in-the-same. What would you widget do if there were multiple events on the same date?

Avatar
TF-35Lightning

Community Member, 137 Posts

12 August 2010 at 3:22pm

UncleCheese in that instance I would show both rollover texts under the 1 rollover (write half the amount of characters in each event rolover brief so it fits).

So you think it cant be done?

If that cant be done the only other thing I can think of that might help me is being able to choose the dot point/image that is displayed for the event. If I am able to select that from 5-6 different ones when I create the event it that would help.

So I guess to do that I would need to specificy different hasEvent classes or??? How would I do that?

Avatar
TF-35Lightning

Community Member, 137 Posts

12 August 2010 at 3:29pm

Unclecheese in my case the maximum amount of events on the same day is 2, and that only happens once or twice throughout the year, so thats where scalability isnt an issue really.

Avatar
UncleCheese

Forum Moderator, 4096 Posts

12 August 2010 at 3:29pm

Of course it can be done. Anything can be done in Silverstripe. It just needs to be thought through.

Try this:

On line 206 in CalendarUI.class.php, there's an array that accepts all the data for a given day in the calendar. You'll see that "HasEvent" is one field. After that entry in the array, add:

'Events'          => $this->calendar->Events(null, $this->date_counter->date(), $this->date_counter->date()),

And on LiveCalendarWidget.ss:

<td class="$Today $OutOfMonth $CurrentDay $HasEvent">
<a href="$ShowDayLink">$Number</a>
<% if Events %><% control Events %><a href="$Event.Link">$Event.Title</a><% end_control %><% end_if %>
</td>

Avatar
TF-35Lightning

Community Member, 137 Posts

13 August 2010 at 6:10pm

UncleCheese thats great thanks for that. The only issue I have now is that $LiveCalendarWidget appears to be initially its own copy of jquery-1.2.6.min.js when the template I am calling $LiveCalendarWidget already is loading the latest jQuery library.

I see    Requirements::javascript(THIRDPARTY_DIR.'/jquery/jquery.js'); being called from CalendarEvent.php I tried commenting that out but no luck.

How do I stop it from loading that jQuery libraryt???

And final question, how would I go about being able to add an image to the cell that the hasEvent class appears on. I'd like to be able to choose from 5-10 little icons in the CMS then have that select appear in the hasEvent cell.

Thanks again for all the help and putting this together.