- 2008-07-05 (土) 21:55
今回はPearを使ってカレンダー表示ページを作成します。Pearとカレンダーパッケージについては以前にも参考にさせていただいたことのあるmukoさんのブログエントリーが分かりやすいです。コメントも含めて参考にさせていただきました。
creative@interactive ≫ CakePHPとカレンダー表示(2)
まずは下記のようにvendorフォルダにPEARとカレンダーパッケージを配置します。

・app/vendors/pear_ini.php
[sourcecode language='php']
define(‘PEAR_PATH’, dirname(__FILE__) . DS . ‘PEAR’);
ini_set(‘include_path’, PEAR_PATH . PATH_SEPARATOR . ini_get(‘include_path’));
[/sourcecode]
・app/controllers/schedules_controller.php
[sourcecode language='php']
vendor(“pear_ini”);
vendor(“PEAR/Calendar/Month/Weekdays”);
class SchedulesController extends AppController
{
var $name = ‘Schedules’;
var $uses = array(‘Schedule’);
function index($year = null, $month = null)
{
//スケジュール読み込み
$this->set(‘schedules’, $this->Schedule->findAll());
if($year == null || $month == null)
{
$Month = new Calendar_Month_Weekdays( date(‘Y’), date(‘m’), 0 );
$year = date(‘Y’);
$month = date(‘m’);
} else {
$Month = new Calendar_Month_Weekdays( $year, $month, 0 );
}
//PEARよりカレンダー情報を読み込み
$Month->build();
$this->set(‘month’, $Month);
}
}
[/sourcecode]
・app/views/schedules/index.thtml
[sourcecode language='php']
– Test –
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| | ” . $Day->thisDay() . “ |
[/sourcecode]
コメント:0
トラックバック:0
- このエントリーへのトラックバックURL
- http://www.studio-kingdom.com/cakephp/cakephp_training/72/trackback