亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Smarty 計數(shù)器變數(shù)在父檔案中定義,但在子包含檔案中遞增並使用
P粉523335026
P粉523335026 2023-09-01 19:10:23
0
1
707
<p>我喜歡在父 tpl 檔案 (First.tpl) 中定義一個計數(shù)器變量,並在子包含檔案 (Second.tpl) 中遞增並使用它。 </p> <p>但是計數(shù)器不再增加。 </p> <p>首先.tpl:</p> <pre class="brush:php;toolbar:false;">{assign var = "counter" value = 1 scope = "global"} {foreach ...} //iterates at least 100 times {include file='Second.tpl'} {/foreach}</pre> <p>第二個.tpl:</p> <pre class="brush:php;toolbar:false;">{assign var="counter" value = $counter 1} {$counter} //counter does not increase! {if $counter > 10} do-something {/if} // if statement fails always!</pre></p>
P粉523335026
P粉523335026

全部回覆(1)
P粉716228245

這是我用來做類似事情的方法,增加循環(huán)內(nèi)的值,並將該值傳遞給包含的檔案。試試一下:

First.tpl

{assign var="counter" value=0}
{foreach ...} /* iterates at least 100 times */
    {assign var="counter" value=$counter+1}
    {include file='Second.tpl' counter=$counter}
{/foreach}

第二.tpl

#
{$counter} /* Check if counter increase */

{if $counter > 10} do-something {/if}

注意。 - 我將 $counter 初始化為零。

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板