headknocker
Member
Posts: 14
Registered: 11/6/2007
Member Is Offline
|
| posted on 3/18/2008 at 12:19 AM |
|
|
sorted events
With only a few events on the monthly view, the events are sorted, but as I add more events the sorting no longer works. This topic has been
discussed many times but there doesn't seem to be a good answer.
Has anyone discovered the solution to getting a sorted list of events with the monthly view?
|
|
|
kvv
Super Administrator
Posts: 84
Registered: 6/17/2003
Member Is Offline
|
| posted on 3/21/2008 at 12:54 PM |
|
|
to fix this issue please edit calendar.php file
look for
uasort($items,array('calendar','sort_by_time_start'));
in the show_month_event function (approximate line #700) and comment this line.
|
|
|
erik_1099
Junior Member
Posts: 8
Registered: 3/28/2008
Location: Southern California
Member Is Offline
|
| posted on 3/28/2008 at 10:09 PM |
|
|
This worked great, THANK YOU! I just needed to make sure my events (which are daily) did not have a time in them.
However, they are now listing in reverse order, ie ranging from end of the month at the top of the list in descending order to first of the month at
the bottom. Is there a good way to reverse that?
Here's a URL: www.premieregolfsolutions.com/calendar.php?CLmPremiere_Golf_Solutions=3
| Quote: | Originally posted by kvv
to fix this issue please edit calendar.php file
look for
uasort($items,array('calendar','sort_by_time_start'));
in the show_month_event function (approximate line #700) and comment this line. |
|
|
|
mediaworks
Junior Member
Posts: 2
Registered: 3/31/2008
Member Is Offline
|
| posted on 3/31/2008 at 03:25 PM |
|
|
Fixing sort_by_date
this function needs added:
function sort_by_date($_a,$_b){
return ($a[1] < $b[1]) ? -1 : 0;
}
then the uasort line becomes:
usort($items,array('calendar','sort_by_date'));
used with the show_month_event() function this will work to sort by date in order.
|
|
|
headknocker
Member
Posts: 14
Registered: 11/6/2007
Member Is Offline
|
| posted on 4/8/2008 at 09:16 PM |
|
|
mediaworks,
Are you sure? kvv's solution worked fine, but when I made your change things became unsorted.
With kvv's solution things look good, except events that occur on the same day are not time ordered.
kvv,
Any ideas on getting events date and time ordered?
|
|
|
mediaworks
Junior Member
Posts: 2
Registered: 3/31/2008
Member Is Offline
|
| posted on 4/10/2008 at 06:33 PM |
|
|
sorry wrong function
function sort_by_date($_a,$_b){
$a = $_a->day;
$b = $_b->day;;
if ($a == $b) return 0;
return ($a < $b) ? -1 : 1;
}
this one works great for me, i agree the previous was broke.
|
|
|
erik_1099
Junior Member
Posts: 8
Registered: 3/28/2008
Location: Southern California
Member Is Offline
|
| posted on 4/10/2008 at 07:34 PM |
|
|
That works! Hooray! Thank you. So, in conclusion, I used KVV's modifications, and the modification below (along with the usort mod above) and got a
monthly list, in order from the first to the last of the month. My events do not have times, and are one per day.
| Quote: | Originally posted by mediaworks
function sort_by_date($_a,$_b){
$a = $_a->day;
$b = $_b->day;;
if ($a == $b) return 0;
return ($a < $b) ? -1 : 1;
}
this one works great for me, i agree the previous was broke. |
|
|
|
erik_1099
Junior Member
Posts: 8
Registered: 3/28/2008
Location: Southern California
Member Is Offline
|
| posted on 4/10/2008 at 07:37 PM |
|
|
In summary, here's what to do:
In the file cl_files/calendar.php:
Add the following code:
function sort_by_date($_a,$_b){
$a = $_a->day;
$b = $_b->day;;
if ($a == $b) return 0;
return ($a < $b) ? -1 : 1;
}
then the uasort line (around line 700) should be changed to:
usort($items,array('calendar','sort_by_date'));
Once those changes are made, use the show_month_event() function and make sure your events do not have times. This is for showing a monthly listing of
daily events. Thanks to kvv and mediaworks for sorting this out.
This should probably checked and stickied.
|
|
|