中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

ECShop中基本的控制函數(shù)標(biāo)簽的使用參數(shù)和方法

1970-01-01    來源:

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用

ECSHOP模板系統(tǒng)控制標(biāo)簽介紹說明,本文將為您介紹ecshop中基本的控制函數(shù)標(biāo)簽的使用參數(shù)和方法,其中包括if標(biāo)簽、foreach標(biāo)簽、for標(biāo)簽等,其實Smarty 中的 if 語句和 php 中的 if 語句一樣靈活易用,并增加了幾個特性以適宜模板引擎, if必須于/if 成對出現(xiàn). 可以使用 else 和 elseif 子句。

if,elseif,else

描述:

Smarty 中的 if 語句和 php 中的 if 語句一樣靈活易用,并增加了幾個特性以適宜模板引擎. if必須于 /if 成對出現(xiàn). 可以使用 else 和 elseif 子句. 可以使用以下條件修飾詞:eq、ne、neq、gt、lt、lte、le、gte、ge、is even、is odd、is not even、is not odd、not、mod、div by、even by、odd by、==、!=、>、=. 使用這些修飾詞時必須和變量或常量用空格格開。

例子:

{if $name eq "Fred"}
Welcome Sir.
{elseif $name eq "Wilma"}
Welcome Ma'am.
{else}
Welcome, whatever you are.
{/if}
{* an example with "or" logic *}
{if $name eq "Fred" or $name eq "Wilma"}
...
{/if}
{* same as above *}
{if $name == "Fred" || $name == "Wilma"}
...
{/if}
{* the following syntax will NOT work, conditional qualifiers
must be separated from surrounding elements by spaces *}
{if $name=="Fred" || $name=="Wilma"}
...
{/if}
{* parenthesis are allowed *}
{if ( $amount  1000 ) and $volume >= #minVolAmt#}
...
{/if}
{* you can also embed php function calls *}
{if count($var) gt 0}
...
{/if}
{* test if values are even or odd *}
{if $var is even}
...
{/if}
{if $var is odd}
...
{/if}
{if $var is not odd}
...
{/if}
{* test if var is divisible by 4 *}
{if $var is div by 4}
...
{/if}
{* test if var is even, grouped by two. i.e.,
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc. *}
{if $var is even by 2}
...
{/if}
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
{if $var is even by 3}
...
{/if}

foreach,foreachelse

iteration:

iteration 用于顯示當(dāng)前循環(huán)的執(zhí)行次數(shù)[待考]
iteration 總是從 1 開始,每執(zhí)行一次增加 1.[待考]

first:

當(dāng)前 foreach 循環(huán)第一次執(zhí)行時 first 被設(shè)置成 true.

last:

當(dāng)前 foreach 循環(huán)執(zhí)行到最后一遍時 last 被設(shè)置成 true.

show:

show 是 foreach 的一個參數(shù). 取值為布爾值 true 或 false. 如果指定為 false 該循環(huán)不顯示,如果循環(huán)指定了 foreachelse 子句,該子句顯示與否也取決于 show 的取值。

total:

total 用于顯示循環(huán)執(zhí)行的次數(shù),可以在循環(huán)中或循環(huán)執(zhí)行后調(diào)用。

屬性 類型 是否必須 缺省值 描述
from string Yes n/a 待循環(huán)數(shù)組的名稱
item string Yes n/a 當(dāng)前處理元素的變量名稱
key string No n/a 當(dāng)前處理元素的鍵名
name string No n/a 該循環(huán)的名稱,用于訪問該循環(huán)

描述:

foreach 是除 section 之外處理循環(huán)的另一種方案(根據(jù)不同需要選擇不同的方案)。

foreach 用于處理簡單數(shù)組(數(shù)組中的元素的類型一致),它的格式比 section 簡單許多,缺點是只能處理簡單數(shù)組。

foreach 必須和 /foreach 成對使用,且必須指定 from 和 item 屬性。
name 屬性可以任意指定(字母、數(shù)字和下劃線的組合)。
foreach 可以嵌套,但必須保證嵌套中的 foreach 名稱唯一。
from 屬性(通常是數(shù)組)決定循環(huán)的次數(shù)。
foreachelse 語句在 from 變量沒有值的時候被執(zhí)行。

例子1:

{* 該例將輸出數(shù)組 $custid 中的所有元素的值 *}
{foreach from=$custid item=curr_id}
id: {$curr_id}

{/foreach}

輸出:

id: 1000

id: 1001

id: 1002

例子2:

{* The key contains the key for each looped value
assignment looks like this:
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
*}
{* 鍵就是數(shù)組的下標(biāo),請參看關(guān)于數(shù)組的解釋 *}
{foreach name=outer item=contact from=$contacts}
{foreach key=key item=item from=$contact}
{$key}: {$item}

{/foreach}
{/foreach}

輸出:

phone: 1

fax: 2

cell: 3

phone: 555-4444

fax: 555-3333

cell: 760-1234

foreach 循環(huán)有自己的變量名,使用該變量名可以訪問該循環(huán). 使用方法為{$smarty.foreach.foreachname.varname},其中 foreachname 即在 foreach 中指定的name 屬性。

以上就是關(guān)于ECShop中基本的控制函數(shù)標(biāo)簽的使用參數(shù)和方法的全部內(nèi)容,感謝大家的閱讀,更多內(nèi)容請關(guān)注西部數(shù)碼技術(shù)頻道網(wǎng)站。

標(biāo)簽: 網(wǎng)站 西部數(shù)碼 選擇

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:ecshop數(shù)據(jù)庫ecs_stats短時間內(nèi)會變很大的解決方法

下一篇:ECshop商品相冊顯示順序修改成正序的方法