Programme page for bTween

The task is to create a dynamic page for displaying the daily programme information of this three-day event.

Features:

  1. The length of each slot gives the users a general idea about how long each session is.
  2. The sessions may be held in more than one place at the same time. A second column in the same row appears for such a situation. A sql script is used to detect whether there is another session held in the same time, and if so, which to be loaded first.
  3. Sessions are sorted by date (using Drupal's View module).
  4. Using CSS to load defferent backgrounds as the timeline.

program page snapshot from b.Tween

The code

<?php
// detect whether there is any session held at the same time
$result = db_query("SELECT nid FROM {content_type_session}  WHERE field_session_start_time_value = '%s' 
AND nid!=%d", $node->field_session_start_time[0]['value'], $node->nid);
$num = db_num_rows($result);
// detect which session gets loaded first
$result_first = db_query("SELECT nid FROM {content_type_session}  WHERE field_session_start_time_value = '%s' 
AND nid!=%d", $node->field_session_start_time[0]['value'], $node->nid);
$first = db_num_rows($result_first);
$raw_width = 440/($num+1);
if ($num && $first==1) {
    $class = "multiple-parent";
    $width = $raw_width + 60;
} else if ($num && $first!=1) {
    $class = "multiple-child";
    $width = $raw_width;
} else {
    $class = "single";  
    $width = 540;
}
 

  $starttime= $node->field_session_start_time[0]['value'];
  $endtime= $node->field_session_start_time[0]['value2'];
  $span = ($endtime - $starttime)/60;   //the hieght 
  if ($span>=0 && $span<=30) {
     $height = "session-height-1";
  } else if ($span >=31 && $span<=60) {
     $height = "session-height-2";
  } else if ($span >=61 && $span <=90) {
     $height = "session-height-3";
  } else {
     $height = "session-height-4";
  }

?>
<div class="node-session <?php print $class.' '.$height;?>" style="width:<?php print $width;?>px;">

  <div class="session-time">
      <?php
          print date('H:i', $node->field_session_start_time[0]['value']) ;
      ?>
  </div>

<div class="session-detail">
 <?php if ($node->field_session_location[0]['view']) { ?>
  <span class="session-location">
      <?php
          print $node->field_session_location[0]['view'];
      ?>
  </span>
 <?php } ?>

  <h3 class="session-title">
      <?php
          print l($node->title, 'node/'.$node->nid);
      ?>
  </h3>
    <?php 
    $result = array();
// load details of speakers from another content type "bio"
    foreach($node->field_session_speakers as $speaker) {
           print $speaker['view'];  
           $bio = db_result(db_query("SELECT bio.field_biocompany_value FROM {node} nd LEFT JOIN {content_type_bio} bio 
           ON nd.nid=bio.nid WHERE nd.nid=%d AND nd.type='%s'", $speaker['nid'], 'bio'), 0);
           if ($bio) { print ' ('.$bio.')';  }
           print "<br />";           
    }
    ?>
</div>