2010年2月16日火曜日

アットページズSmartyテスト

MySmarty.class.php
//Smarty本体をインクルードします。
require_once("Smarty.class.php");

//Smartyのコアクラスを継承します。
class MySmarty extends Smarty{
    //コンストラクタを定義
    public function __construct(){
        $this->Smarty();
        $this->template_dir="./templates";
        $this->compile_dir="./templates_c/";
        $this->cache_dir="./cache/";
        //
        $this->caching=FALSE;
    }
}

?>sample.php
//MySmartyクラスをインクルード
require_once("MySmarty.class.php");

//MySmartyをインスタンス化して変数MyNameに値をセット
$o_smarty=New MySmarty();
$o_smarty->assign("MyName","WAVE,Taro");

//以上の設定に基づいて、テンプレートファイルを呼出
$o_smarty->display("sample.tpl");
?>sample.tpl



sample_test


私の名前は{$MyName}です。


test結果;私の名前はWAVE,Taroです。
になります

0 件のコメント:

コメントを投稿