Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8043 Posts in 1856 Topics- by 2099 Members - Latest Member: roi
Calendar Script CommunityCustomizationCustomizing CalendarScript (Moderators: scott, DanO, Marty)Adding Date and Time to Event View
Pages: [1] 2 3   Go Down
Print
Author Topic: Adding Date and Time to Event View  (Read 1546 times)
0 Members and 1 Guest are viewing this topic.
canadaman
New Member
*

Karma: 0
Offline Offline

Posts: 0

Sysadmin


WWW
« on: November 05, 2002, 01:08:00 PM »

EDIT:
OK, I've gotten a lot of requests for everything on one page. Hopefully this will do it.

Adding the time to the event view has already been covered here: http://www.calendarscript.com/support/forum/Forum4/HTML/000009.html

and adding the date has been covered here: http://www.calendarscript.com/support/forum/Forum4/HTML/000169.html

but in a rather jumbled way.

For all you newbies out there (like me) here's a condensed HOW-TO on getting this working.
BEWARE: The smiley's here are actual colon D's. That's colon-space-D. You'll need to change that in the pasted code or things won't work. I may have missed a few so be careful!

First you need to get the time to work. This required editting calendar.pl so be sure to make a backup!

Thanks to Kent for this mod:

1) In Calendar.pl,

Find:
code:

# Call-back method to get events
*Template::getEvents = \&getEvents;
*Template::getEvent = \&getEvent;

Replace with:
code:

# Call-back method to get events
*Template::getEvents = \&getEvents;
*Template::getEvent = \&getEvent;
*Template::getEvent2 = \&getEvent2;

2) Also in Calendar.pl,

Find the subroutine "getEvent", below it add this new subroutine:

code:

##################################################
# Subroutine called by Template to get the schedule
##################################################
sub getEvent2 {
my ($id2) = @_;
my ($db2) = new DBFile($schedule_db);
my ($event2) = $db2->getRecord( {'event_id'=>$id2 } );
return $event2;
}

3) Almost done... Open default.html

Find:
code:

elsif ($VIEW eq "Event") {
$EVENT->{'details'} = &getEvent($in{'event_id'});
$db = $main: BEvents;
$fields = &main: BGetFieldsInDisplayOrder($db);

Replace with:
code:

elsif ($VIEW eq "Event") {
$EVENT->{'details'} = &getEvent($in{'event_id'});
$db = $main: BEvents;
$fields = &main: BGetFieldsInDisplayOrder($db);
$EVENT2->{'schedule'} = &getEvent2($in{'event_id'});

4) Lastly, add the new fields in the html display area.

On default.html, find the event-only html display area.

code:

<TABLE BORDER="0" CELLPADDING="2" CELLSPACING="0">
<%
   foreach (@$fields) {
   next unless ($db->{'properties'}->{$_}->{'display_details'});
%>

to
code:

<TABLE BORDER="0" CELLPADDING="2" CELLSPACING="0">
         
<TR>
<TD ALIGN="right"><STRONG>Date:</STRONG></TD>
<TD><%= $MONTH_NAME %> <%= $DATE %>, <%= $YEAR %></TD>
</TD>
                  
<SPAN CLASS="text"><TR>
<TD ALIGN="right"VALIGN="top"><B>Time:</B></TD>
<TD ALIGN="left" VALIGN="top">
<% if ( $EVENT2->{'schedule'}->{'all_day'})
{
   print "All Day";
}
elsif ($EVENT2->{'schedule'}->{'start_time'} == $EVENT2->{'schedule'}->{'end_time'})
{
   print
   &Date::formatTime($EVENT2->{schedule}->{start_time},
   $Config->get("time_format"));
}
#----DISPLAYS START AND END TIMES
else
{
   print
   &Date::formatTime($EVENT2->{schedule}->{start_time},
   $Config->get("time_format")), " - ",
   &Date::formatTime($EVENT2->{schedule}->{end_time} ,
   $Config->get("time_format"));
}%> </TD>
</TR></SPAN>
   
<%
   foreach (@$fields) {
   next unless ($db->{'properties'}->{$_}->{'display_details'});
%>


This will display the dates. Thanks go to TubaDave
At the top of default.html change

code:

elsif ($VIEW eq "Event") {
$EVENT->{'details'} = &getEvent($in{'event_id'});
$db = $main: BEvents;
$fields = &main: BGetFieldsInDisplayOrder($db);
}

to
code:

elsif ($VIEW eq "Event") {
$EVENT->{'details'} = &getEvent($in{'event_id'});
$db = $main: BSchedule;
$schedules = &Event::getEventsInRange($db,timegm(0,0,0,$DATE,$MONTH-1,$YEAR-1900),timegm(0,0,0,$DATE+1,$MONTH-1,$YEAR-1900)-1);
foreach (@$schedules) {
if ($_->{event_id} == $EVENT->{details}->{id}) {
$EVENT->{schedule} = $_;
last;
}
}
$db = $main: BEvents;
$fields = &main: BGetFieldsInDisplayOrder($db);
}

Now go to the EVENT VIEW section. Here's the code I added to display the date.

code


<TR>
<TD ALIGN="right"><STRONG>Date:</STRONG></TD>
<TD><%= $MONTH_NAME %> <%= $DATE %>, <%= $YEAR %></TD>
</TD>

That should do it!

[This message has been edited by canadaman (edited June 19, 2003).]

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #1 on: November 05, 2002, 05:15:00 PM »

** I'm no PERL expert so I don't know how the logic is working here. But if you take out the elseif the start and end times are displayed. **

Are they both the same? The logic of that code is that if both times are the same, only print the start time.

If all day, print "All Day"
If not all day and both start and end times are the same, just print the start time.
If neither, print both start and end times.

If this is not the way it is working, you can reverse the logic somewhat:

if ( $event->{'schedule'}->{'all_day'}) {
print "All Day";
} elsif ($event->{'schedule'}->{'start_time'} != $event->{'schedule'}->{'end_time'}) {
print &Date::formatTime($EVENT2->{schedule}->{start_time}, $Config->get("time_format")), " - ",
&Date::formatTime($EVENT2->{schedule}->{end_time} , $Config->get("time_format"));
} else {
print &Date::formatTime($EVENT2->{schedule}->{start_time},$Config->get("time_format"));
}

(note the != in the code above)

Which is:

If all day, print "All Day"
If not all day and start and end times are NOT the same, print both start and end times.
If neither, print just the start time.


Dan O.

------------------

Logged
canadaman
New Member
*

Karma: 0
Offline Offline

Posts: 0

Sysadmin


WWW
« Reply #2 on: November 05, 2002, 05:59:00 PM »

Hi Dan,

The times are not the same. That's what confused me. The logic sure LOOKS different but I can't get anything to proceed past the elseif statement. I had to comment it out to get both times to display. It makes me nervous that I'll screw something up. Right now when there's no end time it displays the start time twice. Annoying but not terrible.

Maybe the quotes around "start_time" and "end_time" in the if statement aren't referring to start_time and end_time like the original coder thought. They'd both be zero and so it would always equate to true. The all day setting doesn't work so that's my thinking. But I'm not sure how to fix it.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #3 on: November 05, 2002, 10:02:00 PM »

I see where the problem is. Instead of

elsif ($event->{'schedule'}->{'start_time'} ==
$event->{'schedule'}->{'end_time'}) {

it should be

elsif ($EVENT2->{'schedule'}->{'start_time'} ==
$EVENT2->{'schedule'}->{'end_time'}) {

If that doesn't work, you could try removing the single quotes from around each of the reference elements like:

$EVENT2->{schedule}->{start_time}

But it should work either way.

Dan O.

------------------

Logged
canadaman
New Member
*

Karma: 0
Offline Offline

Posts: 0

Sysadmin


WWW
« Reply #4 on: November 06, 2002, 01:02:00 PM »

Yay!

That did it. The quotes don't seem to have any effect at all. I tried it both ways until I realized that EVENT2 had to be in all caps. I'm used to php where you can't start a variable with a capital letter.

Thanks Dan! All us newbies appreciate you helping us out.

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #5 on: November 06, 2002, 01:14:00 PM »

BTW, you'll also have to correct the following line or it won't ever work either.

if ( $event->{'schedule'}->{'all_day'}) {

Dan O.

------------------


[This message has been edited by DanO (edited November 06, 2002).]

Logged
melbell
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #6 on: January 05, 2003, 11:31:00 AM »

Could someone please make a final posting of all the correct code to make the date and time show up in the event info (and "All Day" if it's an all day event). I tried following this post but all I could get was a starting time and the current date of today. So I was clearly doing something wrong. :|

Thanks.

------------------
><>  ><>  ><>  ><>  ><>
It is always better to light a candle than to curse the darkness.

Logged

><>  ><>  ><>  ><>  ><>
It is always better to light a candle than to curse the darkness.
John
Guest
« Reply #7 on: January 05, 2003, 11:59:00 AM »

I would also appreciate if someone could assemble a complete listing of this mod.

Also could somebody show a link to a working example of this.

Thanks
John

Logged
janedsh
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #8 on: June 10, 2003, 12:29:00 PM »

It's been awhile since the last post....has anyone been able to locate a copy of the corrected changes in one file?

------------------

Logged
janedsh
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #9 on: June 18, 2003, 11:44:00 AM »

OK - I tried following all the changes but it's still not working.

I get an error on line 63 which refers to this line:

$schedules = &Event::getEventsInRange($db,timegm(0,0,0,$DATE,$MONTH-1,$YEAR-1900),timegm(0,0,0,$DATE+1,$MONTH-1,$YEAR-1900)-1);

Can someone tell me if they see a glitch there somewhere?

------------------

Logged
paulmarx
New Member
*

Karma: 0
Offline Offline

Posts: 0

Electronics Technician


WWW
« Reply #10 on: October 17, 2003, 03:42:00 PM »

I scrupulously followed the whole discussion above
and got exactly the same problem the previous poster
asks about:

==========================
$schedules = &Event::getEventsInRange($db,timegm(0,0,0,$DATE,$MONTH-1,$YEAR-1900),timegm(0,0,0,$DATE+1,$MONTH-1,$YEAR-1900)-1);
==========================

where should I look for the fix to this?

Nobody is obligated to debug all this stuff, obviously,
and this is a very nicely done forum with some heroic
contributions by some members.  That said, it disappointing
when questions about a recurrent topic - like adding
time/date to details - just prompts a link to come see
THIS thread.  

I also note another oddness, perhaps unrelated:
earlier in the original posting of this thread, we
are instructed:
=============
3) Almost done... Open default.html


Find:
code:


elsif ($VIEW eq "Event") {
$EVENT->{'details'} = &getEvent($in{'event_id'});
$db = $main: BEvents;
$fields = &main: BGetFieldsInDisplayOrder($db);


Replace with:
code:


elsif ($VIEW eq "Event") {
$EVENT->{'details'} = &getEvent($in{'event_id'});
$db = $main: BEvents;
$fields = &main: BGetFieldsInDisplayOrder($db);
$EVENT2->{'schedule'} = &getEvent2($in{'event_id'});
=====================


........but farther down the same posting, we are told
this modification, which seems to eliminate the previous
change (last line above.)  Either way I get the error the previous poster has mentioned.


=========================
This will display the dates. Thanks go to TubaDave
At the top of default.html change


code:


elsif ($VIEW eq "Event") {
$EVENT->{'details'} = &getEvent($in{'event_id'});
$db = $main: BEvents;
$fields = &main: BGetFieldsInDisplayOrder($db);
}


to
code:


elsif ($VIEW eq "Event") {
$EVENT->{'details'} = &getEvent($in{'event_id'});
$db = $main: BSchedule;
$schedules = &Event::getEventsInRange($db,timegm(0,0,0,$DATE,$MONTH-1,$YEAR-1900),timegm(0,0,0,$DATE+1,$MONTH-1,$YEAR-1900)-1);
foreach (@$schedules) {
if ($_->{event_id} == $EVENT->{details}->{id}) {
$EVENT->{schedule} = $_;
last;
}
}
$db = $main: BEvents;
$fields = &main: BGetFieldsInDisplayOrder($db);
}

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #11 on: October 17, 2003, 05:42:00 PM »

Adding dates and times to the Event View page is included in the Meta Calendar plug-in at the Unofficial CalendarScript - Mods and Plugins site. See if looking at the code and instructions for it help.

Dan O.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #12 on: April 09, 2005, 01:10:00 AM »

is there a way to adjust this code so that if its an event with a date range, the date field will show that range?  the events with a range, just show the first day of the range....


also.....(not as important)....but for reoccuring events, have the date show...."Every Tuesday", etc....that would be pretty sweet...

brewster

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 230

Please don't PM me. Post in the open forum.


WWW
« Reply #13 on: April 09, 2005, 01:46:00 AM »

** is there a way to adjust this code... **

That may be possible but I've never really looked into it to see exactly what would be needed.

** have the date show...."Every Tuesday" **

That too might be possible but I would think it would be considerably more difficult to achieve. Things that would be reasonably easy to do would be those items which are already fields in the events.txt or schedule.text data files.

JFYI

Dan o.

------------------

Logged
beneath_the_ashes
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #14 on: June 12, 2005, 12:08:00 AM »

its been awhile since the last post....has anyone been able to show date ranges in the event view?

------------------

Logged
Pages: [1] 2 3   Go Up
Print
Jump to: