headknocker
Member
Posts: 17
Registered: 11/6/2007
Location: Virginia
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: 86
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: 7
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: 17
Registered: 11/6/2007
Location: Virginia
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: 7
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: 7
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.
|
|
|
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 |
|
|
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.
|
|
|
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 |
|
|
disregard. I played around and tripped across the right place.
|
|
|
McJohn
Newbie
Posts: 1
Registered: 10/27/2009
Member Is Offline
|
| posted on 10/27/2009 at 08:22 AM |
|
|
Maybe this is not the right place for it..But is good...Thanks for sharing it..
Regards
McJohn
____
dossier surendettement
|
|
|
jessicawats
Newbie
Posts: 1
Registered: 11/6/2009
Member Is Offline
|
| posted on 11/6/2009 at 07:06 AM |
|
|
At last I found the site I've been trying to look for. I miss type the site's name last time. Wheewww...
regards,
jessica
Simulation prêt
|
|
|
gobak
Junior Member
Posts: 2
Registered: 11/17/2009
Member Is Offline
|
| posted on 11/17/2009 at 08:03 PM |
|
|
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.
|
|
|