約 5,383,309 件
https://w.atwiki.jp/r1025/pages/58.html
forみたいな動き(section) !--{section name=test start=1 loop=$row step=1}-- startとstepは省略可能 !--{if $smarty.section.test.first}-- 最初 !--{/if}-- !--{if $smarty.section.test.iteration % 5 == 1}-- 5行おき !--{/if}-- !--{if $smarty.section.test.last}-- 最後 !--{/if}-- 現在のループインデックスは !--{$smarty.section.test.index}-- 回目です。 (0又はstart属性の値から始まり、1又はstep属性の値ずつ増加) 現在ループは !--{$smarty.section.test.iteration}-- 回目です(1からスタート)。 !--{/section}-- ループの最後のインデックスは !--{$smarty.section.test.loop}-- です。 ループトータル回数は !--{$smarty.section.test.total}-- 回です。 トータル: - /今日: - /昨日: -
https://w.atwiki.jp/allegory/pages/32.html
Smarty PHPで使用されるテンプレートエンジン ロジックとコンテンツを分離する事が可能なので、プログラマーとデザイナーの仕事を分離する事が可能。 概要 高速 コンパイルは一度だけ行われる カスタム関数及び 変数の修正子をカスタム定義する事によって、 テンプレート言語を強力に拡張する事が可能 条件式には シンプルな式から複雑な式まで自由に指定可能 section, if等は無制限にネスト可能 PHPコードを埋め込む事が可能(必ずしも、推奨ではない) キャッシュ機能 メモ 日付関連 外部リンク Smartyマニュアル
https://w.atwiki.jp/tmogmni/pages/3.html
インストール Smarty 動くかテスト Smarty セットアップ用のクラスを作成 Smarty セットアップ用のクラスを作成その2 Shift_JISでテンプレート作成時に文字化け html_optionsでlabel属性がついてしまう smartyの関数メモ サーバにアップしたら画面が表示されないエラー インストール (ApacheとPHPが既にインストールされているという前提) Smarty本体を http //smarty.php.net/ からダウンロード。ダウンロードしたファイル(Smarty-x.x.x.tar.gz)を解凍すると以下のファイルができあがる。 [ディレクトリ] demo libs←これのみ必要 misc unit_test [ファイル] COPYING.lib BUGS ChangeLog FAQ INSTALL NEWS QUICK_START README RELEASE_NOTES TODO PHPインストールフォルダ以下にSmartyを置くフォルダを作成。(ここでは c \php\lib\Smarty とする) 解凍したlibs以下のファイル・フォルダ全てをc \php\lib\Smarty以下にコピーする。この時点でのフォルダ構成は以下。 c \php\lib\Smarty ∟ internals(ディレクトリ) plugins(ディレクトリ) Config_File.class.php Smarty.class.php Smarty_Compiler.class.php debug.tpl php.iniファイルに以下のパスを記述して上書き保存。 include_path = ".;c \php\lib\Smarty" Apacheを再起動して完了。 Smarty 動くかテスト Apacheのドキュメントルート以下にSmartyテスト用フォルダを作成(ここでは SmartyTest とする)。SmartyTestフォルダに以下のフォルダとファイルを作成。 注)本来はセキュリティを考慮して下記4つのディレクトリはApacheのドキュメントルート以外に置いたほうがよい。もし置くなら、.htaccessファイルなどでwebから直接参照できないようにしておいたほうが吉。 [フォルダ構成] htdocs\SmartyTest ∟index.php cache(ディレクトリ) config(ディレクトリ) templates_c(ディレクトリ) templates(ディレクトリ) ∟sample.tpl [index.phpの内容] ?php //Smartyライブラリ読み込み require_once("Smarty.class.php"); $smarty = new Smarty; $smarty- assign( title , タイトル ); $smarty- assign( name , お名前 ); $smarty- display( sample.tpl ); ? [sample.tplの内容] html head title {$title} /title /head body 名前:{$name} /body /html http //localhost/SmartyTest/index.php にアクセス。エラー出なければOK。 Smarty セットアップ用のクラスを作成 Smartyを使うときに毎回「require_once("Smarty.class.php");」やら「$smarty- template_dir = "xxxx";」やら書くのは効率が悪いので、専用のSmarty設定クラスを作成する。 [SmartySetup.php] ?php require_once("Smarty.class.php"); class SmartySetup extends Smarty { public function __construct() { $this- Smarty(); //Smartyで用いるディレクトリの設定 $this- template_dir = "c /xxxx/templates/"; $this- compile_dir = "c /xxxx/templates_c/"; $this- config_dir = "c /xxxx/config/"; $this- cache_dir = "c /xxxx/cache/"; } } ? 使うときは以下のようにする。ちょっとだけ書くのが楽。 [index.php] ?php require_once("SmartySetup.php"); $smarty = new SmartySetup; $smarty- display("index.tpl"); ? Smarty セットアップ用のクラスを作成その2 [SmartySetup.php] ?php require_once("Smarty.class.php"); class SmartySetup extends Smarty { public function __construct($smarty_data = array(), $tpl_name) { $this- Smarty(); // 設定 $this- template_dir = "smarty/template"; $this- compile_dir = "smarty/template_c"; $this- config_dir = "smarty/config"; $this- cache_dir = "smarty/cache"; $this- caching = 0; // キャッシュ無効 1で有効 // テンプレート文字化け対策用プリフィルタとポストフィルタ $this- register_prefilter(array($this, pre1 )); $this- register_postfilter(array($this, post1 )); // データをアサインしてテンプレートを表示 $this- assign($smarty_data); $this- display($tpl_name); // アサインしたデータを破棄 $this- clear_all_assign(); } // プリフィルタ public function pre1($tpl_source, $smarty) { return mb_convert_encoding($tpl_source,"EUC-JP","SJIS"); } // ポストフィルタ public function post1($tpl_source, $smarty) { return mb_convert_encoding($tpl_source,"SJIS","EUC-JP"); } } ? 使うときは以下のようなかんじ [index.php] ?php require_once("SmartySetup.php"); $data = array( "data1"= "ほげー" ,"data2"= "ほげほげー" ); $tpl = "index.tpl"; $smarty = new SmartySetup($data, $tpl); ? [index.tpl] html head title index /title /head body データその1:{$data1} br データその2:{$data2} br /body /html index.phpにアクセスして以下のように表示されるはず(未検証) データその1:ほげー データその2:ほげほげー Shift_JISでテンプレート作成時に文字化け sjisでテンプレートファイルを作成したら、「施設」という文字でエラーになった。回避策は{literal}で囲う。(sjisで作らないことが一番の回避策?) {literal}施設{/literal} Smartyのプリフィルタとポストフィルタを使えばいちいち{literal}で囲わなくてもOKだけど、やや強引な感は否めない... function pre01($buff, $smarty) { return mb_convert_encoding($buff,"EUC-JP","SJIS"); } function post01($buff, $smarty) { return mb_convert_encoding($buff,"SJIS","EUC-JP"); } $smarty = new Smarty; $smarty- register_prefilter( pre01 ); $smarty- register_postfilter( post01 ); $smarty- display( index.tpl ); {html_options}でlabel属性がついてしまう label属性を削除するには、smartyフォルダ/plugins/function.html_options.phpの99行目を以下のように修正。 $_html_result = option value=" . smartyの関数メモ URLエンコード {$text|escape url } スペースやタブを削除 {strip}{/strip}で囲う デバッグ {debug} (別ウインドウでデバッグウインドウが立ち上がる) 中括弧を表示させる 右側中括弧 {rdelim} 左側中括弧 {ldelim} サーバにアップしたら画面が表示されないエラー PHP+smartyを用いてローカル環境で開発していたものをサーバにそのままアップするとエラーが出て画面が表示されない場合がある。サーバにアップした際に以下の操作をしておけば大体大丈夫? smartyコンパイルディレクトリ内ファイル(template_c以下)を全部削除 smartyキャッシュディレクトリ内ファイル(cache以下)を全部削除 smartyのtemplate_c、cache、configディレクトリの権限を777
https://w.atwiki.jp/tohtawa/pages/14.html
smarty 設定 http //www.easy-in.net/?p=3 全部自分で設定 http //fkob.net/e46.html smartyとは vendors\smarty - 元smartyのライブラリファイル)ディレクトリ以下のファイルで定義されている function(function_smarty_function_**) はtplファイル内"{}"で使用可能。
https://w.atwiki.jp/soyjoynice/pages/45.html
※この訳はかなり怪しいよ The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading. section要素は、そのドキュメントあるいはアプリケーションの包括的なひとまとまりを表す。 ここで言うsectionは、コンテンツの(特にヘッダ部分を含む)主たるまとまりのことを指しています。 * * * 参考: http //www.w3.org/TR/2011/WD-html5-20110525/sections.html#the-section-element
https://w.atwiki.jp/lucier/pages/14.html
[EC-CUBE]オススメ商品の列を増やす EC-CUBEでトップページなどにおすすめ商品を表示させる場合、デフォルトでは2列表示になっている。 これを3列ずつ表示させるには、 ブロック編集画面でオススメ商品を編集する。 !–{section name=cnt loop=$arrBestProducts step=2}– を !–{section name=cnt loop=$arrBestProducts step=3}– にする。(step=2をstep=3に変更) 2つめの商品ブロック div class="recomendright" ~ /div の recomendright を recomendleft に変更し、 1行目の !–{assign var=cnt2 value=`$smarty.section.cnt.iteration*$smarty.section.cnt.step-1` }– を !–{assign var=cnt2 value=`$smarty.section.cnt.iteration*$smarty.section.cnt.step-2` }– に変更。 !–{assign var=price01 value=`$arrBestProducts[cnt].price01_min`}– !–{assign var=price02 value=`$arrBestProducts[cnt].price02_min`}– を !–{assign var=price01 value=`$arrBestProducts[$cnt2].price01_min`}– !–{assign var=price02 value=`$arrBestProducts[$cnt2].price02_min`}– に変更。([cnt]を[$cnt2]に) この2つ目の商品ブロックをコピーして追加(1つ目の商品ブロックでもどっちでもいいけど) div class="recomendleft" ~ /div の recomendleft を recomendright に変更し、 !–{assign var=cnt2 value=`$smarty.section.cnt.iteration*$smarty.section.cnt.step-2` }– を !–{assign var=cnt3 value=`$smarty.section.cnt.iteration*$smarty.section.cnt.step-1` }– に変更。(var=cnt2 を var=cnt3 に、step-2 を step-1 に) !–{assign var=price01 value=`$arrBestProducts[$cnt2].price01_min`}– !–{assign var=price02 value=`$arrBestProducts[$cnt2].price02_min`}– を !–{assign var=price01 value=`$arrBestProducts[$cnt3].price01_min`}– !–{assign var=price02 value=`$arrBestProducts[$cnt3].price02_min`}– に変更。([$cnt2] を [$cnt3] に) これでおすすめ商品が3列に!
https://w.atwiki.jp/omisono_php/pages/46.html
XAMPPにSmartyをインストールする方法 1 Smartyをダウンロードしてくるhttp //www.smarty.net/ 2009/04/13現在では Smarty 2.6.22 Released が最新版 zip形式を選択 2 解凍したZIPのlibsフォルダをXAMPPのPHPフォルダにコピーする c \xampp\php\ にコピーする 3 php.iniを変更して、smartyを読み込ませる php.ini中のinclude_pathにsmartyの記述を追加 例:Cドライブ直下にXAMPPをインストールしていた場合 include_path = .;C \xampp\php\pear\;c \xampp\php\libs ; 注意 XAMPPの場合、php.iniが3つ存在する。 (php/php.ini, php/php4/php.ini, apache/bin/php.ini) その中で有効なのはapache/binフォルダのphp.ini あとは無視をしてもOK 4 apacheを再起動
https://w.atwiki.jp/freebsd7/pages/19.html
Smartyとは Smartyとは、PHPプログラミングにおいて、ロジックとデザインを分離して 開発ができる便利な手法(?)です。 例えば、普通のASPで作成したページは、 htmlの中にVBコードをガンガンに書いていき、1つのhtml(asp)ファイルで動作します。 また、普通にPHPでソースを書く際も同じです。 この方法だと視認性が悪く、デザインと分離できないため、 html部分だけをデザイナーに頼んで作ってもらうと言うことができません。 そこで、htmlとソースコードを別々に管理して 切り離しができるようにするのがSmartyの役目です。 Smartyのインストール 設定 プログラミング http //www13.plala.or.jp/naka_jima/php/chapter10.html http //sky.freespace.jp/smarty/SmartyManual_2-6-6J_html/ http //ft-lab.ne.jp/cgi-bin/wiki.cgi?page=%A5%C6%A5%F3%A5%D7%A5%EC%A1%BC%A5%C8%A5%A8%A5%F3%A5%B8%A5%F3%A1%CASmarty%A1%CB_PHP ↓ ↓ ↓ ↓ ↓ ↓ 以下、広告です。↓ ↓ ↓ ↓ ↓ ↓
https://w.atwiki.jp/bithouse/pages/22.html
?php define( SMARTY_DIR , /home/be-bee/smarty/ ); require_once( SMARTY_DIR . Smarty.class.php ); // Smartyオブジェクト取得 function getSmartyObj() { static $smarty = null; if( is_null( $smarty ) ){ $smarty = new Smarty(); $smarty- template_dir = /home/be-bee/www/worker/smarty/templates/ ; $smarty- compile_dir = /home/be-bee/www/worker/smarty/templates_c/ ; $smarty- config_dir = /home/be-bee/www/worker/smarty/configs/ ; $smarty- cache_dir = /home/be-bee/www/worker/smarty/cache/ ; } return $smarty; } ?
https://w.atwiki.jp/sevenlives/pages/1190.html
Smarty 読み:すまーてぃ 英語:smarty 別名: 意味: Smartyとは、PHPのテンプレート・エンジンのこと。 コンパイル型のテンプレート・エンジンであり、一度生成したファイルをPHPスクリプトとしてキャッシュしておくため高速に動作します。 Smartyの特徴としてファイル単位のキャッシングだけでなくページの部分単位でもキャッシング出来るので柔軟なコンテンツのキャッシングが可能になります。 構文が豊富でかつシンプル、機能もプラグインという形で拡張もできるという特徴があります。 テンプレートエンジンを利用することで、デザインとロジックの区別を明確にルール付けすることができ、メンテナンス性が向上します。 2011年06月14日 テンプレート・エンジン PHP プレースホルダ フィルタ(Smarty)?プリ・フィルタ? ポスト・フィルタ? アウトプット・フィルタ? ■ プラグイン(Smarty)? テンプレート関数プラグイン(Smarty)? リソース・プラグイン? インサート・プラグイン?