Jump to:

10986 Posts in 2724 Topics by 1817 members

All other Modules

SilverStripe Forums » All other Modules » Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class

Discuss all other Modules here.

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

Page: 1 2 3
Go to End
Author Topic: 1778 Views
  • TF-35Lightning
    Avatar
    Community Member
    137 Posts

    Re: Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class Link to this post

    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?

  • TF-35Lightning
    Avatar
    Community Member
    137 Posts

    Re: Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class Link to this post

    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?

  • TF-35Lightning
    Avatar
    Community Member
    137 Posts

    Re: Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class Link to this post

    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?

  • TF-35Lightning
    Avatar
    Community Member
    137 Posts

    Re: Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class Link to this post

    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>

  • TF-35Lightning
    Avatar
    Community Member
    137 Posts

    Re: Trying to extend event_calendar with minor change, adding rollover popup/tool tip to hasEvent class Link to this post

    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.

    1778 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.