Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: sorted events
headknocker
Member

Posts: 12
Registered: 11/6/2007
Member Is Offline
posted on 3/18/2008 at 12:19 AM Reply With Quote
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?
View User's Profile View All Posts By User U2U Member
kvv
Super Administrator

Posts: 81
Registered: 6/17/2003
Member Is Offline
posted on 3/21/2008 at 12:54 PM Reply With Quote

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.
View User's Profile View All Posts By User U2U Member
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 Reply With Quote

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.
View User's Profile View All Posts By User U2U Member
mediaworks
Junior Member

Posts: 2
Registered: 3/31/2008
Member Is Offline
posted on 3/31/2008 at 03:25 PM Reply With Quote
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.
View User's Profile View All Posts By User U2U Member
headknocker
Member

Posts: 12
Registered: 11/6/2007
Member Is Offline
posted on 4/8/2008 at 09:16 PM Reply With Quote

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?
View User's Profile View All Posts By User U2U Member
mediaworks
Junior Member

Posts: 2
Registered: 3/31/2008
Member Is Offline
posted on 4/10/2008 at 06:33 PM Reply With Quote
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.
View User's Profile View All Posts By User U2U Member
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 Reply With Quote

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.
View User's Profile View All Posts By User U2U Member
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 Reply With Quote

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.
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Product Page
Product Demonstrations Live Demos
Free/Trial Script Download Free Download
Product Documentation Documentation
Documentation page
Change Log
Support Forum Support Forum
Order Now ORDER NOW!
Add to Cart
View Cart
 

Go To Top


Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004