<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="center">Smarty - the compiling PHP template engine</th></tr><tr><td width="25%" align="left" valign="bottom"><a href="plugins.modifiers.html" accesskey="P">Prev</a></td><td width="50%" align="center" valign="bottom">Chapter 16. Extending Smarty With Plugins</td><td width="25%" align="right" valign="bottom"><a href="plugins.compiler.functions.html" accesskey="N">Next</a></td></tr></table> # Block Functions[塊函數] > void smarty_block_name($params, $content, &$smarty, &$repeat); array $params; mixed $content; object &$smarty; boolean &$repeat; Block functions are functions of the form: {func} .. {/func}. In other words, they enclose a template block and operate on the contents of this block. Block functions take precedence over custom functions of the same name, that is, you cannot have both custom function {func} and block function {func}..{/func}. By default your function implementation is called twice by Smarty: once for the opening tag, and once for the closing tag. (See $repeat below on how to change this.) Only the opening tag of the block function may have attributes. All attributes passed to template functions from the template are contained in the $params variable as an associative array. The opening tag attributes are also accessible to your function when processing the closing tag. The value of the $content variable depends on whether your function is called for the opening or closing tag. In case of the opening tag, it will be NULL, and in case of the closing tag it will be the contents of the template block. Note that the template block will have already been processed by Smarty, so all you will receive is the template output, not the template source. The parameter $repeat is passed by reference to the function implementation and provides a possibility for it to control how many times the block is displayed. By default $repeat is TRUE at the first call of the block-function (the opening tag) and FALSE on all subsequent calls to the block function (the block's closing tag). Each time the function implementation returns with $repeat being TRUE, the contents between {func}...{/func} are evaluated and the function implementation is called again with the new block contents in the parameter $content. If you have nested block functions, it's possible to find out what the parent block function is by accessing $smarty->_tag_stack variable. Just do a var_dump() [http://php.net/var_dump] on it and the structure should be apparent. 塊函數的形式是這樣的:{func} .. {/func}。換句話說,他們被封閉在一個模板區域內,然后對該區域的內容進行操作。塊函數優先于同名的自定義函數,即是說,你不能同時使用自定義函數{func}和塊函數{func} .. {/func}。 默認地,你的函數實現會被Smarty調用兩次:一次是在開始標簽,另一次是在閉合標簽(參考下面的&$repeat關于怎樣改變這種設置)。 只有塊函數的開始標簽具有屬性。所有屬性包含在作為關聯數組的$params變量中,經由模板傳遞給模板函數。當處理閉合標簽時,函數同樣可訪問開始標簽的屬性。 $content變量值取決于你的函數是被開始標簽調用還是被閉合標簽調用。假如是開始標簽,變量值將為NULL,如果是閉合標簽,$content變量值為模板塊的內容。請注意這時模板塊已經被Smarty處理過,因此你所接收到的是模板的輸出而不是模板資源。 &$repeat參數通過引用傳遞給函數執行,并為其提供控制塊顯示多少次的可能性。默認情況下,在首次調用塊函數(塊開始標簽)時&$repeat變量為true,在隨后的所有塊函數(閉合標簽)調用中其值始終為false。函數每次執行返回的&$repeat值為true時,{func} .. {/func}之間的內容會被求值,同時參數$content里的新塊內容會再次調用執行函數(譯注:運行方法有點類似遞歸函數)。 如果你嵌套了塊函數,可以通過$smarty->_tag_stack變量訪問找出父塊函數。只須對塊函數運行一下[var_dump()](http://php.net/var_dump),函數結構就可以一目了然了。 <table width="100%" border="0" cellpadding="0" cellspacing="0" class="EXAMPLE"><tr><td><div class="EXAMPLE"> <a name="AEN4165" id="AEN4165"> </a> <b>Example 16.5. block function</b> <br/><strong>例16-5.塊函數 </strong> <table border="0" bgcolor="#E0E0E0" width="100%"><tr><td><pre class="PROGRAMLISTING">&lt;?php/* * Smarty plugin * ------------------------------------------------------------- * File: block.translate.php * Type: block * Name: translate * Purpose: translate a block of text * ------------------------------------------------------------- */function smarty_block_translate($params, $content, $smarty, &amp;$repeat){ // only output on the closing tag if(!$repeat){ if (isset($content)) { $lang = $params['lang']; // do some intelligent translation thing here with $content return $translation; } }}?&gt;</pre></td></tr></table><p> 參見<a href="api.registerplugin.html">registerPlugin()</a>、<a href="api.unregisterplugin.html">unregisterPlugin()</a>。</p></div></td></tr></table> <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="plugins.modifiers.html" accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="plugins.compiler.functions.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Modifiers<br/> 調節器</td><td width="34%" align="center" valign="top"><a href="plugins.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Compiler Functions<br/> 編譯函數</td></tr></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>

                              哎呀哎呀视频在线观看