OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Sorting by room_id

Are you responsible for making OCS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, michael, John

Forum rules
What to do if you have a technical problem with OCS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved. Please note that this FAQ is OJS-centric, but most issues are applicable to both platforms.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OCS Conference Support and Discussion subforum; if you have a development question, try the OCS Development subforum.

Sorting by room_id

Postby panthergirl » Tue Apr 19, 2005 7:33 am

Can anyone suggest a way to modify schedule.php so that for a particular day and particular time the presentations are sorted by room_id?

I admit that I don't know PHP and mySQL as well as I should. But I've manage to make lots of modifications on my own without trouble. This one is stumping me, and nothing I read or try seems to help.

This may seem like a minor thing but this may make the difference between the schedule being usuable for us or not, and we've already put a lot of work into it, so "not" is an extremely depressing thought. So please, if you can help me, I'd really appreciate it.
panthergirl
 

I finally figured it out.

Postby panthergirl » Thu Apr 21, 2005 8:05 pm

Now that I have it, it doesn't seem like such a big deal. But this was long in coming (I had been working on it for quite awhile before my previous post, and a non-trivial amount since then).

It's not beautiful, but it works. I'm sure there's a better way.

Instead of the function sortEvents, use this:
Code: Select all
// Sorts by start_time of event, then by room_id
// For this to work, room_id must be added to the two places that
// the $event array is created.
// Unlike sortEvents, which this replaces, this ignores end_time  (all
// of our time slots are the same)
function sortEventsThenRooms($a, $b)
{
   foreach(array('start_time','room_id') as $value ) {
      if ($value=="start_time")   {
           // compare start times

         $start_a = strtotime("$a[$value]");
         $start_b = strtotime("$b[$value]");

         if($start_a != $start_b) { return ($start_a > $start_b) ? 1 : -1; }
        }
        else if ($value=="room_id") {
           if ($a[$value] != $b[$value]) { return $a[$value] > $b[$value] ? 1: -1; }
        }
     }
   return 0;
}
panthergirl
 


Return to OCS Technical Support

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest