home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (calendar-day-overlap.tpl.php)

This example Drupal source code file (calendar-day-overlap.tpl.php) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

calendar, class, div, foreach, last, php, script, table, tbody, td, time_cnt, tr

The calendar-day-overlap.tpl.php Drupal example source code

<?php
// $Id: calendar-day-overlap.tpl.php,v 1.1.2.1 2010/11/28 23:31:28 karens Exp $
/**
 * @file
 * Template to display a view as a calendar day, grouped by time with overlapping items
 * 
 * @see template_preprocess_calendar_day.
 *
 * $rows: The rendered data for this day.
 * $rows['date'] - the date for this day, formatted as YYYY-MM-DD.
 * $rows['datebox'] - the formatted datebox for this day.
 * $rows['empty'] - empty text for this day, if no items were found.
 * $rows['all_day'] - an array of formatted all day items.
 * $rows['items'] - an array of timed items for the day.
 * $rows['items'][$time_period]['hour'] - the formatted hour for a time period.
 * $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
 * $rows['items'][$time_period][$column]['values'] - An array of formatted 
 *   items for a time period and field column.
 * 
 * $view: The view.
 * $columns: an array of column names.
 * $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
 * $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
 * 
 * The width of the columns is dynamically set using <col></col> 
 * based on the number of columns presented. The values passed in will
 * work to set the 'hour' column to 10% and split the remaining columns 
 * evenly over the remaining 90% of the table.
 */
//dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
?>
<div class="calendar-calendar"><div class="day-view">
<div id="multi-day-container">
  <table class="full">
    <tbody>
      <tr class="holder">
        <td class="calendar-time-holder"></td>
        <td class="calendar-day-holder"></td>
      </tr>
      <tr>
        <td class="<?php print $agenda_hour_class ?> first">
           <span class="calendar-hour"><?php print date_t('All day', 'datetime') ?></span>
        </td>
        <td class="calendar-agenda-items multi-day last">
          <?php foreach ($columns as $column): ?>
          <div class="calendar">
            <div class="inner">
             <?php print isset($rows['all_day'][$column]) ? implode($rows['all_day'][$column]) : ' ';?>
            </div>
          </div>
          <?php endforeach; ?>   
        </td>
      </tr>
    </tbody>
  </table>
</div>
<div class="header-body-divider"> </div>
<div id="single-day-container">
  <script>
    try {
  	  // Hide container while it renders...  Degrade w/o javascript support
      $('#single-day-container').css('visibility','hidden');
    }catch(e){ 
      // swallow 
    }
  </script>
  <table class="full">
    <tbody>
      <tr class="holder">
        <td class="calendar-time-holder"></td>
        <td class="calendar-day-holder"></td>
      </tr>
      <tr>
        <td class="first">
          <?php $is_first = TRUE; ?>
          <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
            <?php 
              if ($time_cnt == 0) {
                $class = 'first ';
              }
              elseif ($time_cnt == count($start_times) - 1) {
                $class = 'last ';
              }
              else {
                $class = '';
              } ?>
            <div class="<?php print $class?>calendar-agenda-hour">
              <span class="calendar-hour"><?php print $hour['hour']; ?></span>
              <span class="calendar-ampm"><?php print $hour['ampm']; ?></span>
            </div>
          <?php endforeach; ?>   
        </td>
        <td class="last">
          <?php foreach ($rows['items'] as $time_cnt => $hour): ?>
            <?php 
              if ($time_cnt == 0) {
                $class = 'first ';
              }
              elseif ($time_cnt == count($start_times) - 1) {
                $class = 'last ';
              }
              else {
                $class = '';
              } ?>
          <div class="<?php print $class?>calendar-agenda-items single-day">
            <div class="half-hour"> </div>
            <?php if ($is_first && isset($hour['values'][$column])) :?>
            <div class="calendar item-wrapper first_item">
            <?php $is_first = FALSE; ?>
            <?php else : ?>
            <div class="calendar item-wrapper">
            <?php endif; ?>
              <div class="inner">
               <?php print isset($hour['values'][$column]) ? implode($hour['values'][$column]) : ' '; ?>
              </div>
            </div>
          </div>
          <?php endforeach; ?>   
        </td>
      </tr>
    </tbody>
  </table>
</div>
<div class="single-day-footer"> </div>
</div></div>
<script>
try {
  // Size and position the viewport inline so there are no delays
  calendar_resizeViewport();
  calendar_scrollToFirst();
  $('#single-day-container').css('visibility','visible');
}catch(e){ 
  // swallow 
}
</script>

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal calendar-day-overlap.tpl.php source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.