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: 17
Registered: 11/6/2007
Location: Virginia
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: 86
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: 7
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: 17
Registered: 11/6/2007
Location: Virginia
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: 7
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: 7
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
dante_in_Calgary
Junior Member

Posts: 3
Registered: 6/10/2007
Location: Calgary
Member Is Offline
posted on 11/22/2008 at 08:05 AM Reply With Quote

Not sure what I'm doing wrong here. If I comment out line 700 (uasort) then I get things sorted but in reverse order.

then I try to change the uasort line as indicated above and I try to add the function to the bottom of the code and I get an error:

Warning: uasort(): Invalid comparison function on line 700

Can anybody clarify is there a specific place the new function has to go? Does it need any additional code such as a { or } or /* ?

I'm not much of a PHP guy so any help is appreciated.
View User's Profile View All Posts By User U2U Member
dante_in_Calgary
Junior Member

Posts: 3
Registered: 6/10/2007
Location: Calgary
Member Is Offline
posted on 11/22/2008 at 08:31 PM Reply With Quote

disregard. I played around and tripped across the right place.
View User's Profile View All Posts By User U2U Member
gobak
Junior Member

Posts: 2
Registered: 11/17/2009
Member Is Offline
posted on 11/17/2009 at 08:03 PM Reply With Quote

Hello,
has anyone managed to get this working? If I implement those code changes I get the same message as DanteInCalgary:
Warning: uasort(): Invalid comparison function on line 700

And yet another question: am I somehow able to display months in different language? Not those in calendar but those generated by $date? I am Czech and our website doesn't look good mixed with English words.

Edit. Aha. If I toggle error reporting off, it works! (I guess there are errors still but they just don't show).

-------------------
By the way thanks for the nice stuff, fellows! This is exactly what I need, just to get the monthly events display working correctly and I am happy hippo.
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