Cloud Nine

Avatar

This blog is my everything!!

Mar
06
Smarty のtplに直接ファイルを読み込んで表示させる。
Mar 6, 2008 0

{ fetch file=”表示したいファイルのURL”}

しらなっかた。。。。

http://www.smarty.net/manual/ja/language.function.fetch.php

Feb
26
Smartyの設置方法
Feb 26, 2008 0

本家サイトから、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");

 ↓
完了

Nov
09
Smartyの修飾子
Nov 9, 2007 0

Smartyの修飾子が便利なので忘れないうちにメモしておきます。

使い方

・hoge.php(データの生成)

$smarty = new Smarty;
$smarty->assign(’hoge’, strtotime(’-1 day’));
$smarty->display(’hoge.tpl’);

・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 単語の数を取得 {}

,

Advertisings

Search Keyword

Calendar

2008年 November
« Oct    
 12
3456789
10111213141516
17181920212223
24252627282930

Status

フィードメーター - Cloud  Nine あわせて読みたいブログパーツ