日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Smarty - 手册 - 第8章 自定义函数 - {cycle}循环

發布時間:2023/12/14 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Smarty - 手册 - 第8章 自定义函数 - {cycle}循环 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Smarty - 手冊 - 第8章 自定義函數 - {cycle}循環

{cycle}

{cycle} is used to alternate a set of values. This makes it easy to for example, alternate between two or more colors in a table, or cycle through an array of values.

{cycle} 用于在值集合中輪換。便于實現下述情況,在一個表格中交替輸出兩種或多種顏色,在值數組中循環。

Attribute NameTypeRequiredDefaultDescription
namestringNodefaultThe name of the cycle
valuesmixedYesN/AThe values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values
printbooleanNoTRUEWhether to print the value or not
advancebooleanNoTRUEWhether or not to advance to the next value
delimiterstringNo,The delimiter to use in the values attribute
assignstringNon/aThe template variable the output will be assigned to
resetbooleanNoFALSEThe cycle will be set to the first value and not advanced
  • You can {cycle} through more than one set of values in a template by supplying a name attribute. Give each {cycle} an unique name.

  • You can force the current value not to print with the print attribute set to FALSE. This would be useful for silently skipping a value.

  • The advance attribute is used to repeat a value. When set to FALSE, the next call to {cycle} will print the same value.

  • If you supply the assign attribute, the output of the {cycle} function will be assigned to a template variable instead of being output to the template.

Example 8-5. {cycle}

{section name=rows loop=$data}
<tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}">
<td>{$data[rows]}</td>
</tr>
{/section}

The above template would output:

<tr bgcolor="#eeeeee">
<td>1</td>
</tr>
<tr bgcolor="#d0d0d0">
<td>2</td>
</tr>
<tr bgcolor="#eeeeee">
<td>3</td>
</tr>

[cycle用途]

循環輸出值

[cycle文檔]

http://smarty.php.net/manual/en/language.function.cycle.php

[Smarty下載地址]

http://smarty.php.net/download.php

[Smarty相關論壇]

http://php.board.newsmth.net/

[Smarty關鍵詞]

smarty

[Smarty函數]

借助cycle實現循環輸出值, http://smarty.php.net/manual/en/language.function.cycle.php

Smarty的cat函數, http://smarty.php.net/manual/en/language.modifier.cat.php

Smarty的upper函數, http://smarty.php.net/manual/en/language.modifier.upper.php

{assign}標記, http://smarty.php.net/manual/en/language.custom.functions.php#language.function.assign

escape轉義修飾符, http://smarty.php.net/manual/en/language.modifier.escape.php

counter計數器, http://smarty.php.net/manual/en/language.function.counter.php

[手冊 - 第3章 基礎語法]

Comments注釋, http://smarty.php.net/manual/en/language.basic.syntax.php#language.syntax.comments
Math數學運算, http://smarty.php.net/manual/en/language.math.php

[手冊 - 第7章 內建函數]

{foreach},{foreachelse}, http://smarty.php.net/manual/en/language.function.foreach.php

[手冊 - 第13章 Smarty類方法]

register_function()動態注冊模板函數插件, http://smarty.php.net/manual/en/api.register.function.php

總結

以上是生活随笔為你收集整理的Smarty - 手册 - 第8章 自定义函数 - {cycle}循环的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。