SmartyをXREAに導入する手順を簡単に。
1.アーカイブのダウンロード
http://www.smarty.net/ にアクセス
download it here. をクリック
http://www.smarty.net/download.php に遷移
Latest Stable Release(最新安定版)のSmarty 2.6.19をダウンロード。Windowsの方は、Zip形式のアーカイブを落せば良いでしょう。ダウンロード後は、もちろん解凍して下さい。
2.Smartyのアップロード
サーバーのルートフォルダに「Smarty」ディレクトリを作成します。XREAだと、public_htmlと同じ階層に作成ですね。。
ダウンロードしたSmartyアーカイブのlibsフォルダをXREA側のSmartyフォルダ内にアップロード
これだけでサーバーへの導入は完了です。
3.Smartyを利用するための準備
Smartyを利用するサーバー側のディレクトリ内にtemplates、templates_cの2つのディレクトリを作成して下さい。
templates_cディレクトリのパーミッションは「777」に設定します。
4.Smartyの動作確認
下記のコードを書いた「smarty_test.php」=> templatesフォルダと同じ階層にアップロードします。
<?php
//Smarty
require_once (“/virtual/YOUR_ID/Smarty/libs/Smarty.class.php”);
$tpl = new Smarty;
$tpl -> assign( array(“name” => “まこと”, “email” => “mega@mac.com”, “tel” => “07-7777-7777”));
$tpl -> display(“smarty_test.tpl”);
?>
次に下記のコードを書いた「smarty_test.tpl」=> templatesフォルダの中にアップロードします。
<html>
<head>
<title>Smarty TEST</title>
</head>
<body>
<table>
<tr><th>名前</th><td>{$name}</td></tr>
<tr><th>メール</th><td>{$email}</td></tr>
<tr><th>TEL</th><td>{$tel}</td></tr>
</table>
</body>
</html>
smarty_test.phpにアクセスして表示されればOK。XREAの詳細はコチラから。