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


Login with username, password and session length

Search

 
Advanced search

8240 Posts in 1905 Topics- by 2172 Members - Latest Member: JeffHLB
Calendar Script CommunityEverything ElseGeneral Use (Moderators: scott, DanO)past year of events with end date = current date?
Pages: [1]   Go Down
Print
Author Topic: past year of events with end date = current date?  (Read 2776 times)
0 Members and 1 Guest are viewing this topic.
slbradio
New Member
*

Karma: 0
Offline Offline

Posts: 8


« on: December 15, 2009, 02:51:13 PM »

Is it possible to have a "past events" displayed. . .  with a range of say, a year, ending on 'today's date'. .  so it wouldn't show coming up events just today and prior - in decending order. . .  december 23,22,21. . .  etc. . 

I have tried to modify the

<% @$EVENTS = sort {$b->{schedule}->{start} <=> $a->{schedule}->{start} } @$EVENTS; %>

code with little luck. . .  can only get that to reverse the events on any given day, not actually reverse the day sort. . . 



This is my code currently:

Code:

<!--#include file="preferences. pl"-->
<%
&getEvents( {range=>'year'});
$DAY = $Grid->{'grid'}->[0]->[0];
$EVENTS = $DAY->{events};
$total_events=0;
%>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<%FOREACH EVENTLIST%>
<%IF EVENTS EXIST%>
<%$curr_events = 0;%>
<%FOREACH EVENT%>
<%$curr_events++ if (($EVENT->{details}->{inclusion} ne "No") or ($EVENT->{details}->{inclusion} ne "This Week")); %>
<%/FOREACH%>
<%next unless ($curr_events);%>
<%$total_events++;%>
<tr>
<td colspan="2">
<font size="2" face=" Arial, Helvetica, sans-serif" color="#473903">
<a href="hxxp: slbradio. org/asx/<%=$datestring%>. asx"><strong><%=$DAY->{monthname}%> <%=$DAY->{dd}%></strong> </a>
</font>
</td>
</tr>
<tr>
<td nowrap valign="top" align="right">
<font size="2" face=" Arial, Helvetica, sans-serif" color="#473903">
<%FOREACH EVENT%>
<% next if (($EVENT->{details}->{inclusion} eq "No") or ($EVENT->{details}->{inclusion} eq "This Week") or ($EVENT->{details}->{inclusion} eq "Games")); %>
</font>
</td>
<td valign="top">
<font size="2" face=" Arial, Helvetica, sans-serif" color="#473903">
<A HREF="<%=$CGI_URL%>?calendar=<%=$in{'calendar'}%>&view=Event&event_id=<%= EVENT FIELD(id) %>" STYLE="text-decoration: none; color:663366" CLASS="text"><%= EVENT FIELD(title) %></A>
</font>
</td>
<tr>
<td nowrap valign="top" align="right">
<font size="2" face=" Arial, Helvetica, sans-serif" color="#473903">
&nbsp;&nbsp;<%= # $EVENT->{'details'}->{'title'} %><BR><%= $EVENT->{'details'}->{'title'} %><br>

</font>
</td>
</tr>
<%/FOREACH%>
<%/IF%>
<%/FOREACH%>
</table>
<%unless($total_events){%>
<CENTER><I>No Events</I></CENTER>
<% } %>

Code formatting edited by Dan O.
« Last Edit: December 20, 2009, 01:09:40 AM by DanO » Logged
DanO
Moderator
Sr. Member
*****

Karma: 13
Offline Offline

Posts: 273

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


WWW
« Reply #1 on: December 15, 2009, 08:29:04 PM »

Quote
Is it possible to have a "past events" displayed...

It should definitely be possible although I do not know exactly how to go about it.

Quote
in decending order

That might be more difficult.


Quote

This is my code currently:

&getEvents( {range=>'year'});


That isn't going to work. As the default such a call would retrieve a year's worth of events but from the current date forward. You'd have to calculate a starting date in the past and pass that date ($sd) along with that call. Maybe something like:

&getEvents( { 'range'=>'year', 'startdate'=>$sd } );

JFYI From the documentation:
Quote
startdate : A date in the yyyymmdd format which will be the starting point of the date display range.


Once you can at least achieve event retrieval, you can move along to the sorting problem... which might require modifications to the script itself, not just the template.

JMO

Dan O.
Logged
slbradio
New Member
*

Karma: 0
Offline Offline

Posts: 8


« Reply #2 on: December 16, 2009, 12:56:21 PM »

thanks for the detailed reply. .
I'm not that good with this kind of script so forgive my question but. . .

how do i pass a start date a year in the past?
i suppose I could just do a static start date and just let the list build but i was hoping that it would float to include the past year (or maybe at some point only the last 6 months or something - maybe that's even harder. . . )

so using $sd how do i define that startdate?

thanks again!
Logged
slbradio
New Member
*

Karma: 0
Offline Offline

Posts: 8


« Reply #3 on: December 16, 2009, 01:13:36 PM »

when i use 'startdate'=>'20090501', 'range'=>'year' or a combination of the two values the range seems to override and i seem to just get the whole year. . .

you can check out what my text looks like here:

hxxp: www. slbradio. org/cgi-bin/calendar. pl?template=SLB6ssi. html
Logged
slbradio
New Member
*

Karma: 0
Offline Offline

Posts: 8


« Reply #4 on: December 16, 2009, 01:22:33 PM »

sorry for another reply but

this:
<% @$EVENTS = sort {$b->{schedule}->{start} <=> $a->{schedule}->{start} } @$EVENTS; %>

definitely works when applied to the sort order of a single day's events. . .
there must be a way to modify either 'schedule' or 'start' in there to make it apply to actual days but i can't seem to find the right combination

help is appreciated!
Logged
DanO
Moderator
Sr. Member
*****

Karma: 13
Offline Offline

Posts: 273

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


WWW
« Reply #5 on: December 16, 2009, 05:54:54 PM »

I'll see if I can look into it more but it likely won't be really soon. Maybe by the end of the holidays?

Dan O.
Logged
slbradio
New Member
*

Karma: 0
Offline Offline

Posts: 8


« Reply #6 on: December 17, 2009, 12:32:41 PM »

I really appreciate it Dan!
Logged
DanO
Moderator
Sr. Member
*****

Karma: 13
Offline Offline

Posts: 273

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


WWW
« Reply #7 on: December 19, 2009, 03:16:32 PM »

Here may be the solution to your sorting issue.

From your template delete the <%FOREACH EVENTLIST%> tag. In place of it use the following code:

<%
foreach $datestring (reverse sort keys %$EventList) {
$DAY = $EventList->{$datestring};
my ($EVENTS) = $DAY->{events};
%>



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


To limit the events displayed to events previous to the current date, right after the tag:

<%FOREACH EVENT%>

add this line:

<% next if $TODAY_DATESTRING < $datestring; %>

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

BTW. I do not know if the call &getEvents( {range=>'year'}) just retrieves events from the current year (ie. 2009) or a whole year's worth of events. If the former, on Jan. 1st there may be no events to be displayed. In that case, you'll have to work on or deal with that issue yourself.

Dan O.
Logged
DanO
Moderator
Sr. Member
*****

Karma: 13
Offline Offline

Posts: 273

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


WWW
« Reply #8 on: December 19, 2009, 04:23:35 PM »


Quote
I do not know if the call &getEvents( {range=>'year'}) just retrieves events from the current year (ie. 2009) or a whole year's worth of events.

Through testing it looks to only retrieve events from the current year (ie. 2009, etc.). If you wanted a full year's worth of events period, try this:

Delete the line &getEvents( {range=>'year'}); from your template and replace it with the following two lines:

$target_date = $LAST_YEAR . &Date::LZ($MONTH) . &Date::LZ($PREVIOUS_DAY_DATE);
&getEvents( { 'duration'=>'366d','startdate'=>$target_date } );


Hopefully it should work.

Dan O.

Logged
slbradio
New Member
*

Karma: 0
Offline Offline

Posts: 8


« Reply #9 on: December 19, 2009, 06:58:48 PM »

man!
you just made my day!

all of that code works like a dream!
Thank you so much!

Logged
DanO
Moderator
Sr. Member
*****

Karma: 13
Offline Offline

Posts: 273

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


WWW
« Reply #10 on: December 20, 2009, 01:06:38 AM »

.

Glad to hear it. Thanks for the follow up.

Dan O.
The Unofficial CalendarScript - Mods and Plugins site

.
« Last Edit: December 20, 2009, 01:11:30 AM by DanO » Logged
slbradio
New Member
*

Karma: 0
Offline Offline

Posts: 8


« Reply #11 on: February 01, 2010, 02:24:33 PM »

Noticed this error today.

Quote
ERROR PROCESSING TEMPLATE
There was an error in your template file.  Below is the template file and also the perl code generated from it to help you with debugging.

Day '31' out of range 1. . 28 at /usr/www/users/slbradio/cgi-bin/calendarscript/lib/Date. inc line 191



Any idea what this could mean?
below this error is the code of the page, I can quote that there as well if you need.
Logged
DanO
Moderator
Sr. Member
*****

Karma: 13
Offline Offline

Posts: 273

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


WWW
« Reply #12 on: February 02, 2010, 11:50:43 AM »

Change:

$target_date = $LAST_YEAR . &Date::LZ($MONTH) . &Date::LZ($PREVIOUS_DAY_DATE);

to

$target_date = $LAST_YEAR . &Date::LZ($MONTH) . &Date::LZ($DATE);

The change might cause one day's worth of events to be missing from the list.

Dan O.
Logged
slbradio
New Member
*

Karma: 0
Offline Offline

Posts: 8


« Reply #13 on: February 18, 2010, 12:06:18 PM »

great thank you!
it still seems to work right with that script change.
We'll see on the first of the next month if it breaks again.

The exact date that it goes back in time until isn't crucial, approximately a year is good enough.
Logged
Pages: [1]   Go Up
Print
Jump to: