• ベストアンサー
※ ChatGPTを利用し、要約された質問です(原文:marty3のvariableFilter)

Smarty3.0.9でdefault_modifiersの代わりに使用するvariableFilterについて

このQ&Aのポイント
  • Smarty3ではdefault_modifiersが廃止され、代わりにvariableFilterを使用します。
  • しかし、variableFilterについての詳細な情報はSmarty3のマニュアルには記載されておらず、Web上でもあまり情報が見つかりません。
  • そのため、$this->_smarty->default_modifiers = array('escape:"htmlall"');の代わりの書式については分かりません。

質問者が選んだベストアンサー

  • ベストアンサー
  • Dags
  • ベストアンサー率78% (11/14)
回答No.1

Ver3でも普通に使えますよ。 こちらの環境にてV.3.0.9を入れて動作確認してみましたが問題ありませんでした。 気になった点が1つあり、正常にSmartyがプラグインを読み込んでますか?(modifier.escape.php) 【variableFilter】についてですが、多分プラグインのことでしょう。 $smarty->loadFilter("variable", "htmlspecialchars"); variablefilter.htmlspecialchars.php 一度単体で組んでみては如何でしょうか。 ちなみに、Smartyの最新版は【Ver3.1.6】です。

chopperin
質問者

お礼

Dagsさん、本当に有難うございました。 いやぁ、ご指摘のように、Pluginフォルダを読み込んでいませんでした。 某山○本に書かれていた設定方法を信用して丸飲みして設定したらプラグインの読み込み先が消えておりました。 おかげで他のいくつかの問題も解決しました。 数週間悩んでいたのでスッキリしました。 本当に有難うございました。

全文を見る
すると、全ての回答が全文表示されます。

その他の回答 (1)

  • Dags
  • ベストアンサー率78% (11/14)
回答No.2

訂正です。 訂正前:ちなみに、Smartyの最新版は【Ver3.1.6】です。 訂正後:ちなみに、Smartyの最新版は【Ver3.1.3】です。 誠に申し訳ない。

全文を見る
すると、全ての回答が全文表示されます。

関連するQ&A

  • smartyについて困っております。

    &lt;div style=&quot;color: #ff0000;&quot;&gt;あああ &lt;/div&gt; のようなエスケープしてあるhtmlをmysqlに登録しておりphp側で $smarty->assign('data', $data);と登録データを代入しtpl側で {$data|smarty:nodefaults}とし表示させているのですが <div style="color: #ff0000;">あああ</div>とhtmlではなく文章で 表示されてしまいます。 ※$this->default_modifiers = array('escape:"html"');は適用してます htmlを埋め込み表示させたいのですがどうすればうまく表示させる事が できるのでしょうか?

    • 締切済み
    • PHP
  • smarty3で変数表示について

    smarty3 でエラーが発生しています。 現在自宅のサーバーでsmarty3を勉強しているのですが以下のエラーで困っています。 詳しい方ご教授お願いします。 環境 : CentOS 6.3 PHP 5.3.3 Smarty 3.1.13 読み込んでいるファイル test.php 1 <?php 2 ini_set('display_errors', 1); 3 ini_set('date.timezone','Asia/Tokyo'); 4 define('SMARTY_DIR', 'Smarty/libs/'); 5 require_once( SMARTY_DIR. 'Smarty.class.php'); 6 7 $smarty = new Smarty(); 8 9 $smarty->template_dir = '../templates/'; 10 $smarty->compile_dir = '../templates_c/'; 11 $smarty->config_dir = '../config/'; 12 $smarty->cache_dir = '../cache/'; 13 14 $msg = "テストを表示します"; 15 $smarty->assign('msg', $msg); 16 17 $smarty->display('test.tpl'); 18 19 20 ?> テンプレートファイル 1 <html> 2 {$msg} 3 </html> 表示されるエラー文 Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "../templates/test.tpl" on line 2 "{$msg}" unknown tag "private_print_expression"' in /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php:665 Stack trace: #0 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(451): Smarty_Internal_TemplateCompilerBase->trigger_template_error('unknown tag "pr...', 2) #1 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(2353): Smarty_Internal_TemplateCompilerBase->compileTag('private_print_e...', Array, Array) #2 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(3101): Smarty_Internal_Templateparser->yy_r27() #3 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templateparser.php(3201): Smarty_Internal_Templateparser->yy_reduce(27) #4 /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_intern in /usr/local/lib/php/includes/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 665 テンプレートファイルの{$msg}を削除して動作させるとコンパイルされてはいるようです。 よろしくお願いします。

    • 締切済み
    • PHP
  • define でのルートディレクトリの定義について・・・。パスが納得できません。

    宜しくお願いします。 Smarty を使用して PHPを勉強しています。 Smartyのデフォルトを変更しようと、 「MySmarty」として新規にクラスを作成しました。 ソースの先頭で、 define("ROOT_DIR",$_SERVER['DOCUMENT_ROOT']."/.."); として、ROOT_DIRにルートディレクトリまでのパスを記憶させています。 全ソースは下記をごらんくらさい。 そこで、  define("ROOT_DIR",$_SERVER['DOCUMENT_ROOT']."/.."); にある、最後の ."/.."); が納得いきません。。。 最初の . ピリオドは連結のためのものだとわかりますが、 あとの/.. はディレクトリの階層をあげる指示ですよね? てなると、クラスの定義のなかで使用するルートディレクトリへのパス が、 おかしく思えてきます。書籍の通りにやっているので、 この通りにやるとうまくいっていますが、自分的になっとくがいかなく・・。 ソースは下記のようになってます。 特に $this->template_dir  のテンプレートディレクトリへのパスを 再設定しているところですが、 ROOT_DIR."/templates" ということは、ルート/../templates  となりますよね? 作業フォルダの図はこの通りです。↓ C:\xampp   |   libs     |-MySmarty.class.php (下記のソースファイル)   |   |   templates       |-input.tpl   |  templates_c <省略> なんとなくですが、ルート/../templates  ではなくて、 ルート/templates なようなきがします。 わかりにくい説明だったかもしてませんが、何卒宜しくお願いいたします。 ______________________________ define("ROOT_DIR",$_SERVER['DOCUMENT_ROOT']."/.."); require_once("Smarty.class.php"); class MySmarty extends Smarty { function MySmarty (){ $this->template_dir = ROOT_DIR."/templates"; $this->compile_dir = ROOT_DIR."/templates_c"; $this->left_delimiter = "{{"; $this->right_delimiter = "}}"; $this->default_modifiers = array('escape'); $this->Smarty(); } } ____________________________

    • 締切済み
    • PHP
  • 超初心者なんですが教えてください!

    Warning: htmlspecialchars() expects parameter 1 to be string, array given in C:\xampp\libs\plugins\modifier.escape.php on line 26 はどうゆうエラーですか?? あと、解決方法も教えてください。

    • 締切済み
    • PHP
  • portsの依存関係確認について

    FreeBSD 6.2R を利用しており、過去に cvsup にて ports を最新化した事があります。 ports 導入に際し依存関係を確認しようと下記コマンドを実行しました。 ------------------------------------------------------ # cd /usr/ports/x11/xorg # make pretty-print-run-depends-list This port requires package(s) "" to run. # make pretty-print-build-depends-list # ------------------------------------------------------ xorg は依存関係あるはずなのですが... 試しに下記のコマンドを打つと下記のような結果となります。 ------------------------------------------------------ # make run-depends-list /usr/ports/graphics/dri /usr/ports/x11-drivers/xorg-drivers /usr/ports/x11-fonts/xorg-fonts /usr/ports/x11-servers/xorg-server /usr/ports/x11-themes/xcursor-themes /usr/ports/x11/xbitmaps /usr/ports/x11/xorg-apps /usr/ports/x11/xorg-docs /usr/ports/x11/xorg-libraries # ------------------------------------------------------ INDEX ファイルの問題かと思い portsnap で最新化しました。 ------------------------------------------------------ # portsnap fetch # portsnap extract # portsnap update ------------------------------------------------------ 再度、pretty-print-run-depends-list を行うも変化なしです。 /usr/ports で make index や、portupgrade を入れて、 portsdb -Uu を行うもエラーがでてしまいます。 ------------------------------------------------------ # cd /usr/ports # make index Generating INDEX-6 - please wait..Unknown modifier 'u' Unknown modifier 'u' Unknown modifier 'u' Unknown modifier 'u' Unknown modifier 'u' Syntax error: "||" unexpected ===> arabic/ae_fonts_mono failed *** Error code 1 Unknown modifier 'u' Unknown modifier 'u' Unknown modifier 'u' Unknown modifier 'u' Unknown modifier 'u' Syntax error: Unterminated quoted string ===> accessibility/accerciser failed *** Error code 1 2 errors ******************************************************************** Before reporting this error, verify that you are running a supported version of FreeBSD (see http://www.FreeBSD.org/ports/) and that you have a complete and up-to-date ports collection. (INDEX builds are not supported with partial or out-of-date ports collections -- in particular, if you are using cvsup, you must cvsup the "ports-all" collection, and have no "refuse" files.) If that is the case, then report the failure to ports@FreeBSD.org together with relevant details of your ports configuration (including FreeBSD version, your architecture, your environment, and your /etc/make.conf settings, especially compiler flags and WITH/WITHOUT settings). Note: the latest pre-generated version of INDEX may be fetched automatically with "make fetchindex". ******************************************************************** *** Error code 1 Stop in /usr/ports. *** Error code 1 Stop in /usr/ports. ------------------------------------------------------ 誰か解決策を教えて頂けませんでしょうか。 宜しくお願い致します。

  • Smartのカスタマイズでエラー

    いつもお世話になっております。 Smartyのカスタマイズを行いたく 設置でエラーになってしまいました。 public_htmlと同じ階層にSmartyフォルダを作成しました。 (下記のような構造になっています。) /public_html/ /Smart/configs/ /Smart/lib/ /Smart/templates/ /Smart/templates_c/ ファイルには下記のように記述しております。 /Smart/lib/smarty_setup.php ---------------------------------------- require_once 'Smarty.class.php'; class SmartySetup extends Smarty {  function SmartySetup() {   $this->template_dir = SMARTY_DIR . "templates";   $this->compile_dir = SMARTY_DIR . "templates_c";   $this->cache_dir = SMARTY_DIR . "cache";   $this->config_dir = SMARTY_DIR . "configs";   $this->left_delimiter = "<!--{";   $this->right_delimiter = "}-->";  } } ---------------------------------------- /public_html/smarty.php ---------------------------------------- require_once("../../Smarty/libs/smarty_setup.php"); $smarty = new Smarty(); $smarty->display("smarty.tpl"); ---------------------------------------- 実行すると、下記のようなエラーが表示されてしまいます。 Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'smarty.tpl'' in C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php:163 Stack trace: #0 C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php(541): Smarty_Internal_Template->isExisting(true) #1 C:\*****\Smarty\libs\Smarty.class.php(337): Smarty_Internal_Template->getRenderedTemplate() #2 C:\*****\Smarty\libs\Smarty.class.php(381): Smarty->fetch('smarty.tp...', NULL, NULL, NULL, true) #3 C:\*****\smarty.php(26): Smarty->display('smarty.tp...') #4 {main} thrown in C:\*****\Smarty\libs\sysplugins\smarty_internal_template.php on line 163 どう対処すればいいでしょうか。 よろしくご教示お願いいたします。

    • ベストアンサー
    • PHP
  • smartyについて

    smartyについて 環境は、windows /php-5 / smarty-2.6.17です。 以下の2つエラーが出てどう対処すればいいか困っています。 【1つめ】 Fatal error: Smarty error: [in **.tpl line 10]: syntax error: unrecognized tag: 文--> 【2つめ】 {$errmsg (Smarty_Compiler.class.php, line 446) in C:\xampp\php\PEAR\Smarty\libs\Smarty.class.php on line 1095 【ソース】 呼び先PGは、 $this->smarty->assign("errmsg","ニックネーム"); $this->smarty->display("**.tpl"); テンプレートでは、 <tr id="" class=""> <td id="" class=""><font color="#ff0000">{$errmsg}を入力してください。</font></td> </tr> よろしくお願いいたします。

    • 締切済み
    • PHP
  • smartyのforeachの使い方?

    smartyについて教えてください。 mysqlのデータを繰り返し表示させたいのですが Warning: htmlspecialchars() expects parameter 1 to be string, array given in パス modifier.escape.php on line 26 とエラーが出てしまい動作しません。 foreachの使い方がおかしいのかと思いマニュアルをみてみたのですが わかりませんでした。 どうすれば繰り返し表示できるようになるでしょうか? ---php--- $i = 0; $list = array(); while ($col = mysql_fetch_array($res, MYSQL_ASSOC)) { $list[$i]['id'] = $col[id]; $list[$i]['title'] = $col[title]; $list[$i]['main'] = $col[main]; $i++; } $smarty->assign('list', $list); ---tpl--- {foreach item=list from=$list} <tr> <td>{$list.id}</td> <td>{$list.title}</td> <td>{$list.main}</td> <td><a href="hoge.php?id={$list.id}">a</a></td> <td><a href="hoges.php?id={$list.id}">a</a></td> </tr> {/foreach}

    • ベストアンサー
    • PHP
  • ZendFramework-1.0.2の環境設定

    IndexController.php以外の Controllerファイルが起動いたしません。 以下のようなエラーが出力されます。どのように対処したらよいでしょうか。よろしくお願いいたします。 Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in C:\zend\ZendFramework\library\Zend\Controller\Dispatcher\Standard.php:194 Stack trace: #0 C:\zend\ZendFramework\library\Zend\Controller\Front.php(920): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:\zend\ZendFramework\library\Zend\Controller\Front.php(224): Zend_Controller_Front->dispatch() #2 C:\Apache Group\Apache2.2\htdocs\zdb1\index.php(10): Zend_Controller_Front::run('./application/c...') #3 {main} thrown in C:\zend\ZendFramework\library\Zend\Controller\Dispatcher\Standard.php on line 194

    • ベストアンサー
    • PHP
  • classの使い方について

    とある書籍にて require_once "MDB2.php"; require_once "Smarty.class.php"; class BBS extends Smarty{  private $_db;  public function __construct(){   $this->Smarty();   $this->template_dir = "{$dir}/themes";   $this->compile_dir = "{$dir}/templates_c";   $this->config_dir = "{$dir}/config";   $this->config_load("app.conf",basename($_SERVER["SCRIPT_NAME"],".php"));   $this->security=TRUE;   $this->secure_dir=array("{$dir}/image");   $this->_db=MDB2::connect($this->get_config_vars("db_string"));  }  public function __destruct(){   if(!PEAR::isError($this->_db)) $this->_db->disconnect();  }  public function get_db(){ return $this->_db; } } $Bbs = new BBS(); $db = $Bbs->get_db(); $db->setCharset('ujis'); と、あるのですがサーバーがPHP4の為、それに適用させたいのですがどのようにすればいいのでしょうか。ローカルサーバーはPHP5なので問題ないのですが。 class BBS extends Smarty{  var $_db;  function BBS(){   $this->Smarty();   $this->template_dir = "{$dir}/themes";    ~省略~  }  function shutdown(){   if(!PEAR::isError($this->_db)) $this->_db->disconnect();  }  register_shutdown_function("shutdown");  function get_db(){ return $this->_db; } } 上記で試してみたのですが Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in D:\aki\public_html\1\class\smarty.php on line 33 とエラーが出てしまいデストラクタがうまくできない状態です。 PHP4のクラスについて調べてみたが応用できそうなのが見つからなくて・・・ ご教授を願えたらと思います。

    • 締切済み
    • PHP