smarty

http://d.hatena.ne.jp/xmalloc/20091225/1261709421 のコメントで ・{foreachelse}の存在(これは本当にありがたい) foreachelse って使った事ない なんだ? 値が空の時の処理{foreachelse} - 繰り返し処理 - Smarty - PHP 必要かどうかは わからないけど、…

smartyのtemplate_dirも複数設定しとける

http://techblog.ecstudio.jp/tech-tips/smarty-tip.html plugin_dirとはちょっと動きが違うような気がした 多分 $smarty->template_dir[] = '/hogehogge/mogemoge/view' ; $smarty->template_dir[] = '/hogehogge/mogemoge/view2' ; だと、ダメだった。plug…

resourceプラグイン

テンプレートのソースをDBに入れときたいときとか リソースプラグイン | Smarty Smartyで変数をテンプレートとして,fetch(display)で展開する - LAPISLAZULI HILL#diary 自分では プラギンではストリングを化かすことにした。 何を渡すかはコントローラーで…

eclipseのsmartyエディタ

これよい http://blog.oowarai.com/?p=52

割り当てられた変数の値を返す

これがやりたくて http://labs.unoh.net/2007/06/smartyrails.html # コンテンツ側でテンプレート変数{$LAYOUT}が指定されたらそのファイルをレイアウトとする # {$LAYOUT}が予約語「plain」だったらレイアウトは適用しない これでやれそう http://www.smart…

文字列の結合

$home.moge = "wawawa"; で {include file="$hoge.moge/hoge.tpl"} とかやりたいけどできない .を含んでる場合は、catでつなげる {include file=$hoge.moge|cat:"/hoge.tpl"} でOK マニュアルに書いてあった ヘッダテンプレートにタイトルの変数を渡す | Sma…

escapeなめてた

smartyのエスケープは、いっぱいオプションがあった これ引数ちゃんと3つ目まで、指定しないと危ないかもなぁ。。 function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1') { switch ($esc_type) { case 'html': return ht…

レイアウトテンプレート

うわ、確かにそれでできるわ。。 参考 http://labs.unoh.net/2007/06/smartyrails.html

smartyでforみたいなこと

{section name=cnt loop=10} {$smarty.section.cnt.iteration-1}<br> {/section} {section name=cnt loop=10} {$smarty.section.cnt.index}<br> {/section} {section name=cnt start=0 loop=10} {$smarty.section.cnt.index}<br> {/section} 参考 Smartyでfor文みたいな…

県名ようプラグイン

すばらしっす 2008-05-28 自分で使うようにちょっとだけ手入れ function smarty_function_html_pref($params, &$smarty){ $selected = $params['selected']; $pref_array = array( '01' => '北海道','02' => '青森県', '03' => '岩手県','04' => '宮城県', '…

{html_select_date}でXXXX年XX月XX日ってだしたい

そうかバラせばよかったのか {html_select_date time = "" prefix = "birthday_" start_year = "1920" end_year = "-1" field_order = "Y" field_separator = "" year_empty = "" all_extra = 'class="html_select_date"' }年 {html_select_date time = "" p…

プラグインでカスタムなをつくる

渡すパラメータでつくるarrayをかえたりで、なんでもできる。 呼び側 {custom_hoge_option} プラグイン function smarty_function_custom_hoge_option($params, &$smarty){ require_once $smarty->_get_plugin_filepath('function','html_options'); $option…

プラグインディレクトリは複数していできた

pluginsに突っ込んでいくしかないと思ってた $this->base_dir = "/hoge/fuga/project_root" $this->plugins_dir[] = $this->base_dir . "/inc/Smarty/plugins" ; #default $this->plugins_dir[] = $this->base_dir . "/inc/Smarty/myplugins" ;#自作 でok 参…

ループの回数で処理するしないとか

{if $smarty.section.file.iteration%2 == 0}{/if} rubyだと hoge.each_with_index do |i, count| p count #ループのn回目 end

smartyから色々アクセスできる

PHPの定数にアクセス {$smarty.const.HOGE_FUGA} $_SERVERとか$_GETにアクセス {$smarty.server.SERVER_NAME} その他もろもろ {* (GET) http://www.domain.com/index.php?page=foo から、pageの値を表示 *} {$smarty.get.page}{* (POST) フォームから送信さ…

smartyも結構便利だ

railsのview_helper的なことがしたい。 {php}{/php}でくくる。 適当なフォルダにviewヘルパを作っておいて、そいつをrequireして、 function呼べる。 {php} require_once(APP_DIR."helper/_view_helper.php"); get_categories(1); #_view_helper.phpの中にge…