SmartyはPHP標準のテンプレートエンジンです。
PHP側でオブジェクトSmartyに表示する文字列をassignし、テンプレートファイルでレイアウトを指定することでページのレイアウトを変更することができます。
SmartyはSmartyのホームページからダウンロードできます。また、このページからマニュアルを見ることもできます。
適当なディレクトリでアーカイブファイル(Smarty-2.3.0.tar.gz)を展開します。
Smartyのパスをinclude_pathに追加します。
php.iniファイルを次のように変更します。
include_path = ".:/usr/local/lib/php:/usr/local/apache/phplib:/usr/local/apache/phplib/Smarty" |
Apacheを再起動し、php.iniの変更をデーモンに反映させます。
/usr/local/apache/bin/apachectl restart
Smartyのアーカイブファイルにはテスト用にindex.phpという名前のファイルが含まれています。
Webブラウザーからこのファイルをアクセスし、メッセージが正常に表示されてばインストールは成功です。
デモを実行するには、次の設定が必要です。
上記の設定が終わったら、index.phpにアクセスします。
以下のようなページが表示されたら、成功です。
Title: Welcome To Smarty!
The current date and time is 2002-08-27 16:46:18
Tooltip example: Move your mouse over the Help link to see an example of a tooltip using Smarty's popup function.
The value of global assigned variable $SCRIPT_NAME is /source/Smarty-test/index.php
Example of accessing server environment variable SERVER_NAME: agartha
The value of {$Name} is Fred Irving Johnathan Bradley Peppergill
variable modifier example of {$Name|upper}
FRED IRVING JOHNATHAN BRADLEY PEPPERGILL
|