- 追加された行はこの色です。
- 削除された行はこの色です。
*Smarty [#c63da8dc]
RIGHT:更新日 &lastmod();
**Smartyのインストール [#t1ff2142]
ロジックを作成する作業と、HTMLデザインを編集する作業を分担して行うことが可能になるPHPのテンプレートエンジンとしてSmartyがある。
http://www.smarty.net/download.phpからダウンロード。
***設定 [#uc04dee8]
$ cd /usr/local/src
$ tar zxvf Smarty-2.6.19.tar.gz
$ cd /usr/local/src
$ su
# mv src/Smarty-2.6.19 .
# exit
$ cd
ホームディレクトリに作成するテンプレートを入れるフォルダsmatry_testを作成しディレクトリ構造を作成する(cache/ configs/ templates/ templates_c/を作成)
$ mkdir smatry_test
$ cd smatry_test
$ mkdir cache
$ mkdir configs
$ mkdir templates
$ mkdir templates_c
$ su
# chown -R apache.apache cache
# chown -R apache.apache templates_c
Smartyでwebアクセスする場所をsmarty_testとするため
# mkdir /var/www/html/smarty_test
''設定ファイル''
Smartyの環境を呼び出すのに必要
/var/www/html/smarty_test/init.php
<?php
// Linux スタイル (大文字の 'S' に注意)
define('SMARTY_DIR', '/usr/local/Smarty-2.6.19/libs/'); <==Smartyの展開ディレクトリ
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();
// テンプレート、キャシュ等のディレクトリを指定。
$smarty->template_dir = '/home/okada/smatry_test/templates/';
$smarty->compile_dir = '/home/okada/smatry_test/templates_c/';
$smarty->config_dir = '/home/okada/smatry_test/configs/';
$smarty->cache_dir = '/home/okada/smatry_test/cache/';
?>
/var/www/html/smarty_test/test.phpにアクセスページ(testページ)を指定
<?php
require_once("/var/www/html/smarty_test/init.php");
$smarty->assign('name','JE2ISM');
$smarty->assign('name2','JF2LYU');
//** 次の行のコメントをはずすと、デバッギングコンソールを表示します
//$smarty->debugging = true;
$smarty->display('index.tpl');
$smarty->display('index2.tpl');
?>
''アクセス''
http://(サーバ)/smarty_test/test.php