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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

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


Go to End


19 Posts   2573 Views

Avatar
TF-35Lightning

Community Member, 137 Posts

9 August 2010 at 7:18pm

Hello unclecheese,
I am trying to extend your event_calendar so that I get a rollover popup when I hover the cell <td class="hasEvent">.

Now I have got the jQuery and CSS worked out so this can popup I just neeed to be able to add another field to the CalendarEvent.php so that I can enter some brief text for the rollover to show, and I need to be able to update what the $LiveCalendarWidget outputs so that it shows:

<td class=" hasEvent"> <a href="/silverstripe/silverstripe-v2.4.1/calendar/view/20100820">20<span>This is what will show in the rollover popup</span></a></td>

instead of:

<td class=" hasEvent"> <a href="/silverstripe/silverstripe-v2.4.1/calendar/view/20100820">20</a></td>

So that the text in the span is shown on the rollover.

Are you able to please show me what files I need to modifiy to do this?
For the adding field part I have only ever done this:

class ResultsPage extends Page {
static $db = array(

'Calendarhovertext' => 'Text'

);

function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab('Root.Content.Main', new TextField('Calendarhovertext'), 'Content');

return $fields;
}

etc

I had a look at CalendarEvent.php

I see

static $db = array (
'Recursion' => 'Boolean',
'CustomRecursionType' => 'Int',
'DailyInterval' => 'Int',
'WeeklyInterval' => 'Int',
'MonthlyInterval' => 'Int',
'MonthlyRecursionType1' => 'Int',
'MonthlyRecursionType2' => 'Int',
'MonthlyIndex' => 'Int',
'MonthlyDayOfWeek' => 'Int'
'Rollovertext' => 'Text'
);

I presume I add 'Calendarhovertext' => 'Text' to here.

The public function getCMSFields()
{
$f = parent::getCMSFields();

function looks a bit different than normal, what do I do there???

If you could please show me how to modify that <td> output and what to do with this field would be great.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 August 2010 at 1:36am

You can just copy LiveCalendarWidget.ss to your theme_dir/templates/Includes and change what you need to.

Avatar
TF-35Lightning

Community Member, 137 Posts

10 August 2010 at 3:37pm

UncleCheese

I have copied the LiveCalendarWidget.ss
to my
themes/tutorials/templates/Includes

directory which I am testing on, but it appears that the LiveCalendarWidget.ss is still being read out of the event_calendar/templates directory.

I did a flush and a dev build but still it gets read from there. Is there anything else I have to do to it?

Thanks for the help

Avatar
TF-35Lightning

Community Member, 137 Posts

10 August 2010 at 3:42pm

also UncleCheese I see under LiveCalendarWidget.ss

<% control Days %>
<td class="$Today $OutOfMonth $CurrentDay $HasEvent">
<a href="$ShowDayLink">$Number</a>
</td>
<% end_control %>

Now how do change this control / what is written for this cell for the $HasEvent class only ???

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 August 2010 at 4:31pm

Actually, scratch that. It should go in your parent templates directory, not Includes.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

10 August 2010 at 4:32pm

<% if HasEvent %>

Avatar
TF-35Lightning

Community Member, 137 Posts

10 August 2010 at 4:43pm

ok thanks for that unlcecheese, so now I have

<% control Days %>
<td class="$Today $OutOfMonth $CurrentDay">
<a href="$ShowDayLink">$Number</a>
</td>
<% if HasEvent %>
<td class="$HasEvent">
<a href="$ShowDayLink">$Number<SPAN>This is my rollover text</SPAN></a>
</td>
<% end_if %>
<% end_control %>

But now I double up the hasEvent day in my calendar, so I have day 20, I get a cell with has_Event and one without.

Screenshot
http://gyazo.com/c2c102c0e2984abc2222679b283db040.png

How do I stop that?

Avatar
TF-35Lightning

Community Member, 137 Posts

10 August 2010 at 6:18pm

dont worry unclecheese I worked it out

<% control Weeks %>
<tr>

<% control Days %>
<% if HasEvent %>
<td class="$HasEvent">
<a href="$ShowDayLink">$Number<SPAN>This is my rollover text</SPAN></a>
</td>
<% else %>

<td class="$Today $OutOfMonth $CurrentDay">
<a href="$ShowDayLink">$Number</a>
</td>

<% end_if %>
<% end_control %>
<td class="showWeek">
<a title="<% _t('SHOWWEEK','Show week') %>" href="$ShowWeekLink">&laquo;</a>
</td>

</tr>
<% end_control %>

Go to Top