かめのはこ

とあるエンジニアのメモ帳です

smarty

smartyでassignのscope指定をやってみる

※参考 http://www.smarty.net/docs/ja/language.function.assign.tpl指定できるのは blank Smarty::SCOPE_LOCAL parent Smarty::SCOPE_PARENT root Smarty::SCOPE_ROOT global Smarty::SCOPE_GLOBAL 関連するsmartyモジュールは core/vendors/smarty/sysplug…

smartyでランダム関数を利用する

※rand自体はphpの関数をそのまま利用できる {assign var=hoge value=1|rand:3} //"1|rand:3" の部分は "rand(1,3)" に解釈される 【参考】 ※[php]rand関数 http://php.net/manual/en/function.rand.php ※[smarty]修飾子について http://www.smarty.net/docsv…

cakephpでsmartyを利用する

モジュールをダウンロード ※SmartyView https://github.com/kaz29/smartyview ※Smarty本体 http://www.smarty.net/以下を配置 core/vender/smarty # 本体のlibをsmartyって名前で設置 app/views/smarty.php # smartyviewのphpのみ設置const.phpに Configure:…

smartyで文字列連結

smartyのテンプレートで上で 変数と文字列を結合させる方法※cat: がミソですね // controller $str1 = "one"; $str2 = "two"; $str3 = "3rd"; // template {$str1|cat:$str2|cat:"_"|cat:$str3} // result onetwo_3rd こんなところ