Get Smarty

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Check reviews of PHP Web Hosting, compatible with Smarty Templates

{cycle}

{cycle} は、値の設定に従って循環します。 テーブル内のセルの色を交互に2色もしくはそれ以上の色に変更したり、 配列の値を循環するような事が簡単に行えます。

属性名 必須 デフォルト 概要
name string No default サイクルの名前
values mixed Yes N/A カンマを境界としたリスト (delimiter属性を参照) または値の配列のどちらかによって指定する、循環される値
print boolean No TRUE 値を表示するかどうか
advance boolean No TRUE 次の値に進むかどうか
delimiter string No , value 属性で使用するためのデリミタ
assign string No n/a 出力が割り当てられるテンプレート変数
reset boolean No FALSE 次の値に進まずに、最初の値をセットする。
  • name 属性を渡す事によって、テンプレート内で 1つ以上の値のセットを通して {cycle} を行えます。 各 {cycle} にはユニークな name を与えてください。

  • print 属性に FALSE をセットする事で、 強制的に現在の値を表示しない事が可能です。これは、 こっそり値をスキップするのに役に立つでしょう。

  • advance 属性は値を繰り返すために使われます。 FALSE をセットした時に次の {cycle} が呼ばれると、 同じ値を表示します。

  • assign 属性を指定した場合は、 {cycle} 関数の出力は テンプレートに出力される代わりにテンプレート変数に割り当てられます。

Example 8.5. {cycle}


{section name=rows loop=$data}
<tr class="{cycle values="odd,even"}">
   <td>{$data[rows]}</td>
</tr>
{/section}

  

上のテンプレートの出力


<tr class="odd">
   <td>1</td>
</tr>
<tr class="even">
   <td>2</td>
</tr>
<tr class="odd">
   <td>3</td>
</tr>

  

Comments
No comments for this page.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 14 plus 1? (Are you human?)

Sponsors [info]

Cheap Website Hosting @hostdone.com
Cheap Hosting @HostsVault
email marketing @ActiveCampaign
broadband deals @BroadbandGenie
Best UK Web Hosting @webhost.uk.net
Reliable UK and US Web Hosting @rshosting.com
Cheap US and UK Web Hosting @infrenion.com
I.T Certification Exams @pass-guaranteed.com
Certification Practice Tests @firsttrycertify.com
Certification Practice Exam Questions @ace-it-certifications.com
Broadband Speed Test @broadbandspeed.co.uk
bulk email software @americaint.com