06
- Smarty のtplに直接ファイルを読み込んで表示させる。
- Mar 6, 2008 0
{ fetch file=”表示したいファイルのURL”}
しらなっかた。。。。
http://www.smarty.net/manual/ja/language.function.fetch.php
{ fetch file=”表示したいファイルのURL”}
しらなっかた。。。。
http://www.smarty.net/manual/ja/language.function.fetch.php
本家サイトから、Smarty本体を落してきてください。
↓
解凍すると
Smarty-2.*.*
├demo/
├libs/
├misc/
├unit_test/
└その他ファイル
が現れますが、使うのは「libs」フォルダです。
↓
「libs」をサーバにあげます。
↓
次に「tpl」と「tmp」フォルダを作成します。「tmp」をパーミションを707にします。
↓
Smartyファイルの読み込み。
require_once("./libs/Smarty.class.php");
↓
クラスの呼び出し。
$mySmarty=new Smarty();
↓
各種ファイルの場所を指定
tplの読み込み先
$mySmarty->compile_dir = ("./tpl");
キャッシュの吐き出し先
$mySmarty->template_dir = ("./tmp");
変数を渡します。
$mySmarty->assign("test","Smarty設置テスト");
使用するtplを指定
$mySmarty->display("../tpl/home.tpl");
↓
完了
Smartyの修飾子が便利なので忘れないうちにメモしておきます。
$smarty = new Smarty;
$smarty->assign(’hoge’, strtotime(’-1 day’));
$smarty->display(’hoge.tpl’);
{$hoge|date_format:”%c/%m/%d”}
07/11/08
| 修飾子 | 内容 | 補足 |
| captilize | 単語の頭文字を大文字に変換 | {} |
|---|---|---|
| cat | 指定された変数を連結 | {} |
| lower | 小文字に変換 | {} |
| upper | 小文字に変換 | {} |
| regex_replace | 置き換え(正規表現対応) | {} |
| replace | 置き換え(正規表現未使用) | {} |
| date_format | 日付のフォーマッティング | {} |
| string_format | 文字列のフォーマッティング | {} |
| defaultt | デフォルト値の指定 | {} |
| strip | 空白の除去/置換え | {} |
| defaultt | デフォルト値の指定 | {} |
| strip | 空白の除去/置換え | {} |
| strip_tags | タグの除去 | {} |
| nl2br | 改行文字を タグに変換 |
{} |
| escape | エスケープ処理 | {} |
| spacify | 各文字間にスペースを挿入 | {} |
| truncate | 指定行で文字を切り捨て | {} |
| wordwrap | 指定行でワードラップ | {} |
| indent | インデント | {} |
| count_characters | 文字数を取得 | {} |
| count_paragraphs | パラグラフ数を取得 | {} |
| count_sentences | センテンスを数を取得 | {} |
| count_words | 単語の数を取得 | {} |
,
| 月 | 火 | 水 | 木 | 金 | 土 | 日 |
|---|---|---|---|---|---|---|
| « Oct | ||||||
| 1 | 2 | |||||
| 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
Stay updated on my meandering thoughts & activities via RSS (Syndicate).