<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                <table cellspacing="0" cellpadding="0" border="0" width="100%" summary="Header navigation table"><tbody><tr><th align="center" colspan="3">Smarty - the compiling PHPtemplate engine</th> </tr><tr><td valign="bottom" align="left" width="25%"><a accesskey="P" href="api.registerfilter.html">Prev</a></td> <td valign="bottom" align="center" width="50%">Chapter 13. Smarty Class Methods()</td> <td valign="bottom" align="right" width="25%"><a accesskey="N" href="api.register.object.html">Next</a></td> </tr></tbody></table> # registerPlugin()[注冊插件] Name registerPlugin() ― dynamically register plugins 動態注冊插件 Description void registerPlugin(string type, string name, mixed callback, bool cacheable, mixed cache_attrs); This method registers functions or methods defined in your script as plugin. It uses the following parameters: type defines the type of the plugin. Valid values are "function", "block", "compiler" and "modifier". name defines the name of the plugin. callback defines the PHP callback. it can be either: 1.A string containing the function name 2.An array of the form array(&$object, $method) with &$object being a reference to an object and $method being a string containing the method-name 3.An array of the form array($class, $method) with $class being the class name and $method being a method of the class. cacheable and cache_attrs can be omitted in most cases. See controlling cacheability of plugins output on how to use them properly. 本方法在腳本中注冊函數或方法作為插件。其參數如下: “type”定義插件的類型,其值為下列之一:“function”、“block”、“compiler”和“modifier”; “name”定義插件的函數名; “callback”為定義的php回調函數,其類型為下列之一: 1、包含函數名的字符串; 2、格式為(&$object, $method)的數組,其中,&$object為引用對象,$method為包含方法名的字符串; 3、格式為($class, $method)的數組,其中,$class為類名,$method為類中的方法。 “cacheable”和“cache_attrs”參數大多情況下可以省略。參見[如何正確地控制插件緩存輸出](#)。 <table class="EXAMPLE" cellspacing="0" cellpadding="0" border="0" width="100%"><tbody><tr><td> <div class="EXAMPLE"><strong><a name="AEN31327" id="AEN31327"/>Example 13.27. register a function plugin</strong><b><br/>例13-27.注冊一個<b>函數</b>插件<br/></b><table width="100%" bgcolor="#e0e0e0" border="0"><tbody><tr><td> <pre class="PROGRAMLISTING">&lt;?php$smarty-&gt;registerPlugin("function","date_now", "print_current_date");function print_current_date($params, $smarty){ if(empty($params["format"])) { $format = "%b %e, %Y"; } else { $format = $params["format"]; } return strftime($format,time());}?&gt; And in the template{date_now}{* or to format differently *} {* 或者運用自己的格式化形式 *}{date_now format="%Y/%m/%d"}</pre></td> </tr></tbody></table><p><span class="PROGRAMLISTING"><strong>Example 13.28. register block function plugin</strong></span><b><br/>例13-28.注冊一個<b>塊函數</b>插件</b></p> <table width="100%" bgcolor="#e0e0e0" border="0"><tbody><tr><td><pre class="PROGRAMLISTING">&lt;?php// function declarationfunction do_translation ($params, $content, $smarty, &amp;$repeat, $template){ if (isset($content)) { $lang = $params["lang"]; // do some translation with $content return $translation; }}// register with smarty$smarty-&gt;registerPlugin("block","translate", "do_translation");?&gt; Where the template is:{translate lang="br"}Hello, world!{/translate}</pre></td> </tr></tbody></table><p><strong>Example 13.29. register modifier plugin</strong><b><br/>例13-29.注冊一個<b>調節器</b>插件</b></p> <table width="100%" bgcolor="#e0e0e0" border="0"><tbody><tr><td>&lt;?php<br/> // let's map PHP's stripslashes function to a Smarty modifier. 讓我們將php的stripslashes()函數映射到Smarty調節器中 <br/> $smarty-&gt;registerPlugin("modifier","ss", "stripslashes");<br/> ?&gt;<br/> In the template, use ss to strip slashes.<br/> &lt;?php<br/> {$var|ss}<br/> ?&gt;</td> </tr></tbody></table><p> 參見<a href="api.unregisterplugin.html">unregisterPlugin()</a>、<a href="plugins.writing.html">插件函數</a>、<a href="plugins.block.functions.html">插件塊函數</a>、<a href="plugins.compiler.functions.html">插件編譯函數</a>和<a href="plugins.modifiers.html">建立調節器插件</a>一節。</p> </div> </td> </tr></tbody></table> <table cellspacing="0" cellpadding="0" border="0" width="100%" summary="Footer navigation table"><tbody><tr><td valign="top" align="left" width="33%"><a accesskey="P" href="api.registerfilter.html">Prev</a></td> <td valign="top" align="center" width="34%"><a accesskey="H" href="index.html">Home</a></td> <td valign="top" align="right" width="33%"><a accesskey="N" href="api.register.object.html">Next</a></td> </tr><tr><td valign="top" align="left" width="33%">registerFilter()<br/> 注冊過濾器</td> <td valign="top" align="center" width="34%"><a accesskey="U" href="api.functions.html">Up</a></td> <td valign="top" align="right" width="33%">registerObject()<br/> 注冊對象</td> </tr></tbody></table>
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看