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} 用于在值集合中輪換。便于實現下述情況,在一個表格中交替輸出兩種或多種顏色,在值數組中循環。
| 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用途]
循環輸出值[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.commentsMath數學運算, 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}循环的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JavaScript定时器倒计时60S的
- 下一篇: Linux 摸索:使用VM安装CenOS