HTML Template IT
![]() |
カレンダーを表示、繰り返しの重複。 PEARに最初から付属しているので導入しやすい。(2003/12/09現在) |
htmltplIT.php
require_once 'HTML/Template/IT.php'; require_once 'rkt_calendar.php'; /* HTML_Template_ITオブジェクトの生成 */ $tpl = new HTML_Template_IT('./'); /* テンプレートファイルの読み込み */ $tpl->loadTemplatefile('htmltplIT.tpl', true, true); /* カレンダーオブジェクト */ $objcal = new RKT_calendar($date); $cals = $objcal->getCalendar(); $dates = $objcal->getDates(); $days = array(); foreach ($cals as $weekly=>$days){ foreach ($days as $day){ $tpl->setCurrentBlock('week'); /* ブロック指定 */ $tpl->setVariable('day', $day); /* 変数の受け渡し */ $tpl->parseCurrentBlock('week'); /* ブロック解析 */ } $tpl->setCurrentBlock('cal'); /* ブロック指定 */ $tpl->parseCurrentBlock('cal'); /* ブロック解析 */ } // foreach ($cals as $weekly=>$days) /* 変数の受け渡し */ $tpl->setVariable('month', $dates[RKT_MONTH]); $tpl->show(); /* 表示 */
htmltplIT.tpl
<table cellpadding="3" cellspacing="0" class="calendar"> <tr class="calendar"> <th class="calendar" colspan="7">{month}月</th> </tr> <tr class="calendar"> <td class="holiday">日</td> <td class="calendar">月</td> <td class="calendar">火</td> <td class="calendar">水</td> <td class="calendar">木</td> <td class="calendar">金</td> <td class="saturday">土</td> </tr> <!-- BEGIN cal --> <tr class="calendar"> <!-- BEGIN week --> <td>{day}</td> <!-- END week --> </tr> <!-- END cal --> </table>

