Home · Links · Contact Us
Home arrow Forums
Home
Features
FAQ
Screen Shots
Modules
Themes
Demos
Documentation
Forums
Contact Us
Download
Purchase
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. ..."


  FAQFAQ    SearchSearch  RegisterRegister   Log inLog in 
How to Sort or Order By fields in Get_Event_List

 
Post new topic   Reply to topic     Forum Index -> Hacking Thyme
View previous topic :: View next topic  
Author Message
Buff



Joined: 17 Feb 2007
Posts: 23

PostPosted: Fri Jun 06, 2008 2:49 am    Post subject: How to Sort or Order By fields in Get_Event_List Reply with quote

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
View user's profile Send private message Visit poster's website
esoft_ian



Joined: 12 Sep 2005
Posts: 5268

PostPosted: Mon Jun 09, 2008 6:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Buff



Joined: 17 Feb 2007
Posts: 23

PostPosted: Tue Jun 10, 2008 3:59 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
esoft_ian



Joined: 12 Sep 2005
Posts: 5268

PostPosted: Tue Jun 10, 2008 4:34 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Hacking Thyme All times are GMT
Page 1 of 1

 
Jump to:  
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
© 2005 eXtrovert software unless otherwise noted. All rights reserved.
Portions © 2004 Ben Brown. All rights reserved.
Trademarks are property of their respective owners.