Posts Tagged ‘Smarty’

Smarty 出力フィルター

1月 17th, 2008

EUC-JPで作ったテンプレート出力をSHIFT-JISに変更する方法。

//プラグインの登録
$smarty->plugins_dir = array('plugins',APPLICATION_PATH.'/library/plugins/');
 
//出力フィルターの設定
$smarty->autoload_filters( array("output"=>array("encode_euctosjis")) );

outputfilter.encode_euctosjis.php

function smarty_outputfilter_encode_euctosjis ($buff, &$smarty) {
    $buff = mb_convert_encoding($buff, 'SJIS', 'EUC');
    return $buff;
}

ただし!!
$smarty->append()を使った場合はエンコードされたのを、display()でまたエンコードされてしまいうまくいかない。。

Smarty html_options でonchangeイベント

10月 18th, 2007

ほんと今更ながらの話なのですが、SelectタグでonChangeイベントを使いたい場合{html_options}を使わずforeach文で書いていましたが、html_optionsで表現できるんですね。。
» Read more: Smarty html_options でonchangeイベント

Smarty Splitプラグイン

9月 6th, 2007

前回の
http://smarty.incutio.com/
にある 便利そうな Block Functions SplitとSplit_rowプラグインを試した。

     

  • split – Loop structure similar to foreach that breaks an array into groups as evenly as possible then iterates over those groups. Intended to allow multi column layouts with a minimum of markup in the template code.
  • split_row – A variant of split that returns the chunks as rows instead of as columns

それぞれ block.split.php block.split_row.php ファイルを作りプラグインフォルダに放り込む。
さて、普通ならここで使えるのだが、

Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in /block.split.php on line 104

こんなエラーが。。

調べてみると、どうやら参照渡しのやり方が非推進の方法でやられてるらしい。
http://php.net/manual/ja/ini.core.php

なんとか使えるように修正しようとしたがよくわからず挫折しました^^;
allow_call_time_pass_referenceの設定を1のまま使えるようにした方がいたら教えて下さい><