Smarty - 手册 - 第8章 自定义函数 - {cycle}循环
Smarty - 手冊(cè) - 第8章 自定義函數(shù) - {cycle}循環(huán)
{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} 用于在值集合中輪換。便于實(shí)現(xiàn)下述情況,在一個(gè)表格中交替輸出兩種或多種顏色,在值數(shù)組中循環(huán)。
| name | string | No | default | The name of the cycle |
| values | mixed | Yes | N/A | The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values |
| boolean | No | TRUE | Whether to print the value or not | |
| advance | boolean | No | TRUE | Whether or not to advance to the next value |
| delimiter | string | No | , | The delimiter to use in the values attribute |
| assign | string | No | n/a | The template variable the output will be assigned to |
| reset | boolean | No | FALSE | The 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}
The above template would output:
|
[cycle用途]
循環(huán)輸出值[cycle文檔]
http://smarty.php.net/manual/en/language.function.cycle.php[Smarty下載地址]
http://smarty.php.net/download.php[Smarty相關(guān)論壇]
http://php.board.newsmth.net/[Smarty關(guān)鍵詞]
smarty[Smarty函數(shù)]
借助cycle實(shí)現(xiàn)循環(huán)輸出值, http://smarty.php.net/manual/en/language.function.cycle.php
Smarty的cat函數(shù), http://smarty.php.net/manual/en/language.modifier.cat.php
Smarty的upper函數(shù), http://smarty.php.net/manual/en/language.modifier.upper.php
{assign}標(biāo)記, http://smarty.php.net/manual/en/language.custom.functions.php#language.function.assign
escape轉(zhuǎn)義修飾符, http://smarty.php.net/manual/en/language.modifier.escape.php
counter計(jì)數(shù)器, http://smarty.php.net/manual/en/language.function.counter.php
[手冊(cè) - 第3章 基礎(chǔ)語法]
Comments注釋, http://smarty.php.net/manual/en/language.basic.syntax.php#language.syntax.commentsMath數(shù)學(xué)運(yùn)算, http://smarty.php.net/manual/en/language.math.php
[手冊(cè) - 第7章 內(nèi)建函數(shù)]
{foreach},{foreachelse}, http://smarty.php.net/manual/en/language.function.foreach.php[手冊(cè) - 第13章 Smarty類方法]
register_function()動(dòng)態(tài)注冊(cè)模板函數(shù)插件, http://smarty.php.net/manual/en/api.register.function.php總結(jié)
以上是生活随笔為你收集整理的Smarty - 手册 - 第8章 自定义函数 - {cycle}循环的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JavaScript定时器倒计时60S的
- 下一篇: Linux 摸索:使用VM安装CenOS