|
Quotes |
" ... I want to tell you that your thyme product is functional and valuable beyond
words. I cannot imagine why any portal would be without it. It is the cornerstone of our new project ..."
" ... Thanks for such a complete project, its making my job much easier. ..."
" ... I have now deployed 4 different calendars and our users love them ... "
" ... Easy to install and use and a great look/design. ..."
" ... This has to be the easiest to use program I think I've had to deal with at all this year. ..."
|
|
| View previous topic :: View next topic |
| Author |
Message |
Buff
Joined: 17 Feb 2007 Posts: 23
|
Posted: Fri Jun 06, 2008 2:49 am Post subject: How to Sort or Order By fields in Get_Event_List |
|
|
Anybody:
Now that I have get_event_list working, I have a need to sort the array on the cal_title field.
How can I do this?
Going a step further, can I do a primary sort on the cal_title field and a secondary sort on the event_title field or the event_location field using get_event? _________________ Buff |
|
| Back to top |
|
 |
esoft_ian
Joined: 12 Sep 2005 Posts: 5275
|
Posted: Mon Jun 09, 2008 6:11 pm Post subject: |
|
|
Hi Buff,
Is this a sort per day or an overall sort? E.g. would you no longer like to group the events by date? |
|
| Back to top |
|
 |
Buff
Joined: 17 Feb 2007 Posts: 23
|
Posted: Tue Jun 10, 2008 3:59 am Post subject: |
|
|
Hi Ian,
Since the calendar I'm using get_event_list for is a composite of nine calendars, representing nine districts across the US and Canada, I would like to sort the events by the individual calendars order first, and then by date within each calendar.
If you'll check my work at: http://nsrca.us/components/com_kcal/kcal.php?y=2008&m=5&d=8
I need to sort first by the District number, which is derived from the cal_title field, and then by the date.
I've tried using the PHP 'usort' in conjunction with my own compare function, but that seems to only sort on the date.
I could use get_event_list nine times for the individual calendars, but that doesn't seem to be very elegant programming to me. _________________ Buff |
|
| Back to top |
|
 |
esoft_ian
Joined: 12 Sep 2005 Posts: 5275
|
Posted: Tue Jun 10, 2008 4:34 pm Post subject: |
|
|
Long story short (let me know if you need more and I'll be happy to provide), use usort but do something like this in your custom sort function:
| Code: |
function mysort($a,$b) {
if($a['cal_title'] == $b['cal_title']) {
( insert your existing date comparison code )
}
return strnatcasecmp($a['cal_title'],$b['cal_title']);
}
|
Let me know if you have any questions at all. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|