CakePHPでSmartyを使う環境を作る [PHP]
第11回 Smartyとフレームワーク(その1:CakePHP編)
参考HP: http://www.phpbook.jp/cakephp/install/
SmartyViewのダウンロード。上記のサイトにあったURLはもう存在しないようなので、
http://blog.ecworks.jp/archives/34 こちらから。ReadMeの通り設定。
ただ、smarty1.2用とのことで、そのままでは動作しない。(自分の環境はSmarty1.3)
まず、SmartyViewのサンプルを動作させるため、下記にアクセス(cakephpはcakephpをインストールした場所)。
http://localhost/cakephp/mypages/index
下記エラー発生。
Fatal error: Class 'Smarty' not found SmartyView
バージョンの違いのため?
ReadMeに書いてあるフォルダ構成と自分の環境が異なるため、無理やり変更したら、動いた。
%apache_dir%\htdocs\cakephp\app\vendors\smarty\lib の中身を
%apache_dir%\htdocs\cakephp\app\vendors\smarty へ。
(Smarty.class.php, pluginsフォルダ, syspluginsフォルダ など)
まだ以下のエラーが表示される。
Notice (1024): function call 'assign_by_ref' is unknown or deprecated, use 'assignByRef' [APP\vendors\smarty\sysplugins\smarty_internal_data.php, line 79]
Notice (8): Undefined property: SmartyView::$pageTitle [APP\views\smarty.php, line 163]
Notice (8): Undefined property: SmartyView::$pageTitle [APP\views\smarty.php, line 164] Testing SmartyView
Copyright 2008, ECWorks.
Smarty.class.phpを下記の通り修正してOK。
> $pageTitle = $this->pageTitle
< $pageTitle = @$this->pageTitle
> $this->smarty->assign_by_ref('view', $this);
< $this->smarty->assignByRef('view', $this);
SmartyViewのサンプルが動いたので、今度は 第11回 Smartyとフレームワーク(その1:CakePHP編) の
コードを動作させてみる。
と、日付表示の部分が、表示されない。
(実行結果)
今日はです。
以下を試す。
- phpでの日付出力(date関数) -> OK
- date_formatのパラメータを'%D'に変更 -> NG
- date_format:'%Y年%m月%d日' を "date_format:'%Y年%m月%d日"に変更 -> NG
- date_formatを行わないでそのまま出力 -> OK
コメント 0