Skip to content

Instantly share code, notes, and snippets.

@grega
Created September 17, 2011 13:31
Show Gist options
  • Save grega/49073e88199dd6af05da to your computer and use it in GitHub Desktop.
Save grega/49073e88199dd6af05da to your computer and use it in GitHub Desktop.
For a schedule, such as http://futureofwebapps.com/london-2011/schedule/ (run the loop for each day). Needs to sort by time & then by track, ie. 2 sessions have an 11am start, 1 is 'Track 1' the other is 'Track 2'. 'Track 1' must be listed first.
<?php
function array_push_assoc($array, $key, $value){
$array[$key] = $value;
return $array;
}
$opts = array(
'template'=>'schedule.html',
'page'=>'/page.php',
'skip-template'=>true
);
$day1 = perch_content_custom('Day 1',$opts);
foreach ($day1 as $key => $session) {
if ($session['track1']) {
$session = array_push_assoc($session, 'track', '1');
} elseif ($session['track2']) {
$session = array_push_assoc($session, 'track', '2');
} else {
$session = array_push_assoc($session, 'track', '0');
}
$track[$key] = $session['track'];
$timestart[$key] = $session['timestart'];
$day1[$key] = $session;
}
array_multisort($timestart, SORT_ASC, $track, SORT_ASC, $day1);
foreach ($day1 as $session) {
// output sessions
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment