2004-04-13 08:46:28 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
|
<!-- $Revision$ -->
|
2005-12-09 19:50:41 +00:00
|
|
|
|
<!-- EN-Revision: 1.14 Maintainer: andreas Status: ready -->
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<sect1 id="language.function.section">
|
|
|
|
|
|
<title>section,sectionelse</title>
|
2005-12-09 19:50:41 +00:00
|
|
|
|
<para>
|
|
|
|
|
|
Template-{sections} werden verwendet, um durch <emphasis
|
|
|
|
|
|
role="bold">Arrays</emphasis> zu iterieren (<28>hnlich wie <link
|
|
|
|
|
|
linkend="language.function.foreach">{foreach}</link>). Jedes
|
|
|
|
|
|
<emphasis>section</emphasis>-Tag muss mit einem
|
|
|
|
|
|
<emphasis>/section</emphasis>-Tag kombiniert
|
|
|
|
|
|
werden. <emphasis>name</emphasis> und <emphasis>loop</emphasis> sind
|
|
|
|
|
|
erforderliche Parameter. Der Name der 'section' kann frei gew<65>hlt
|
|
|
|
|
|
werden, muss jedoch aus Buchstaben, Zahlen oder Unterstrichen
|
|
|
|
|
|
bestehen. {sections} k<>nnen verschachtelt werden. Dabei ist zu
|
|
|
|
|
|
beachten, dass sich ihre Namen unterscheiden. Aus der
|
|
|
|
|
|
'loop'-Variable (normalerweise ein Array von Werten) resultiert die
|
|
|
|
|
|
Anzahl der Iterationen, die durchlaufen werden. Wenn ein Wert aus
|
|
|
|
|
|
der 'loop'-Variable innerhalb der {section} ausgegeben werden soll,
|
|
|
|
|
|
muss der 'section-name' umschlossen mit [] angef<65>gt werden.
|
|
|
|
|
|
<emphasis>sectionelse</emphasis> wird ausgef<65>hrt, wenn keine Werte
|
|
|
|
|
|
in der 'loop'-Variable enthalten sind.
|
|
|
|
|
|
</para>
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<informaltable frame="all">
|
|
|
|
|
|
<tgroup cols="5">
|
|
|
|
|
|
<colspec colname="param" align="center" />
|
|
|
|
|
|
<colspec colname="type" align="center" />
|
|
|
|
|
|
<colspec colname="required" align="center" />
|
|
|
|
|
|
<colspec colname="default" align="center" />
|
|
|
|
|
|
<colspec colname="desc" />
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>Attribut Name</entry>
|
|
|
|
|
|
<entry>Typ</entry>
|
|
|
|
|
|
<entry>Erforderlich</entry>
|
|
|
|
|
|
<entry>Standardwert</entry>
|
|
|
|
|
|
<entry>Beschreibung</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>name</entry>
|
|
|
|
|
|
<entry>string</entry>
|
|
|
|
|
|
<entry>Ja</entry>
|
|
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Der Name der 'section'</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>loop</entry>
|
|
|
|
|
|
<entry>[$variable_name]</entry>
|
|
|
|
|
|
<entry>Ja</entry>
|
|
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Der Name des Z<>hlers f<>r die Iterationen.</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>start</entry>
|
|
|
|
|
|
<entry>integer</entry>
|
|
|
|
|
|
<entry>Nein</entry>
|
|
|
|
|
|
<entry><emphasis>0</emphasis></entry>
|
|
|
|
|
|
<entry>
|
|
|
|
|
|
Definiert die Startposition. Falls ein negativer Wert <20>bergeben
|
|
|
|
|
|
wird, berechnet sich die Startposition ausgehend vom Ende des
|
|
|
|
|
|
Arrays. Wenn zum Beispiel 7 Werte in einem Array enthalten sind
|
|
|
|
|
|
und die Startposition -2 ist, ist die berechnete Startposition
|
|
|
|
|
|
5. Unerlaubte Werte (Werte ausserhalb der Gr<47>sse des Arrays)
|
|
|
|
|
|
werden automatisch auf den n<>chstm<74>glichen Wert gesetzt.
|
|
|
|
|
|
</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>step</entry>
|
|
|
|
|
|
<entry>integer</entry>
|
|
|
|
|
|
<entry>Nein</entry>
|
|
|
|
|
|
<entry><emphasis>1</emphasis></entry>
|
|
|
|
|
|
<entry>
|
|
|
|
|
|
Definiert die Schrittweite mit welcher das Array durchlaufen
|
|
|
|
|
|
wird. 'step=2' iteriert durch 0, 2, 4, etc. Wenn ein negativer
|
|
|
|
|
|
Wert <20>bergeben wurde, wird das Array r<>ckw<6B>rts durchlaufen.
|
|
|
|
|
|
</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>max</entry>
|
|
|
|
|
|
<entry>integer</entry>
|
|
|
|
|
|
<entry>Nein</entry>
|
|
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Maximale Anzahl an Iterationen, die Durchlaufen werden.</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>show</entry>
|
|
|
|
|
|
<entry>boolean</entry>
|
|
|
|
|
|
<entry>Nein</entry>
|
|
|
|
|
|
<entry><emphasis>true</emphasis></entry>
|
|
|
|
|
|
<entry>Definiert ob diese 'section' angezeigt werden soll oder nicht.</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</tgroup>
|
|
|
|
|
|
</informaltable>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>section</title>
|
|
|
|
|
|
<programlisting role="php">
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
$data = array(1000,1001,1002);
|
|
|
|
|
|
$smarty->assign('custid',$data);
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{* dieses Beispiel gibt alle Werte des $KundenId Arrays aus *}
|
|
|
|
|
|
{section name=kunde loop=$KundenId}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
id: {$KundenId[kunde]}<br />
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
{* alle Werte in umgekehrter Reihenfolge ausgeben: *}
|
|
|
|
|
|
{section name=kunde loop=$KundenId step=-1}
|
|
|
|
|
|
id: {$KundenId[kunde]}<br />
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<screen>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
id: 1000<br />
|
|
|
|
|
|
id: 1001<br />
|
|
|
|
|
|
id: 1002<br />
|
|
|
|
|
|
<hr />
|
|
|
|
|
|
id: 1002<br />
|
|
|
|
|
|
id: 1001<br />
|
|
|
|
|
|
id: 1000<br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</screen>
|
|
|
|
|
|
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ein weiteres Beispiel, diesmal ohne ein zugewiesenes Array.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=foo start=10 loop=20 step=2}
|
|
|
|
|
|
{$smarty.section.foo.index}
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
<hr />
|
|
|
|
|
|
{section name=bar loop=21 max=6 step=-2}
|
|
|
|
|
|
{$smarty.section.bar.index}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{/section}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<screen>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
10 12 14 16 18
|
|
|
|
|
|
<hr />
|
|
|
|
|
|
20 18 16 14 12 10
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</screen>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
</example>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>section loop Variable</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{* die 'loop'-Variable definiert nur die Anzahl der Iterationen,
|
2005-06-24 09:02:38 +00:00
|
|
|
|
Sie k<>nnen in dieser 'section' auf jeden Wert des Templates
|
2004-04-13 08:46:28 +00:00
|
|
|
|
zugreifen. Dieses Beispiel geht davon aus, dass $KundenId, $Namen und
|
|
|
|
|
|
$Adressen Arrays sind, welche die selbe Anzahl Werte enthalten *}
|
|
|
|
|
|
{section name=kunde loop=$KundenId}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
id: {$KundenId[kunde]}<br>
|
|
|
|
|
|
name: {$Namen[kunde]}<br>
|
|
|
|
|
|
address: {$Adressen[kunde]}<br>
|
|
|
|
|
|
<p>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{/section}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<screen>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
|
|
|
|
id: 1000<br>
|
|
|
|
|
|
name: Peter M<>ller <br>
|
|
|
|
|
|
adresse: 253 N 45th<br>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
id: 1001<br>
|
|
|
|
|
|
name: Fritz Muster<br>
|
|
|
|
|
|
adresse:: 417 Mulberry ln<br>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
id: 1002<br>
|
|
|
|
|
|
name: Hans Meier<br>
|
|
|
|
|
|
adresse:: 5605 apple st<br>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</screen>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>section names</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{*
|
|
|
|
|
|
die 'name'-Variable definiert den Namen der verwendet werden soll,
|
|
|
|
|
|
um Daten aus dieser 'section' zu referenzieren
|
|
|
|
|
|
*}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{section name=meinedaten loop=$KundenId}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<p>
|
|
|
|
|
|
id: {$KundenId[meinedaten]}<br>
|
|
|
|
|
|
name: {$Namen[meinedaten]}<br>
|
|
|
|
|
|
address: {$Adressen[meinedaten]}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>nested sections (verschachtelte 'sections')</title>
|
|
|
|
|
|
<programlisting role="php">
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
$id = array(1001,1002,1003);
|
|
|
|
|
|
$smarty->assign('custid',$id);
|
|
|
|
|
|
|
|
|
|
|
|
$fullnames = array('John Smith','Jack Jones','Jane Munson');
|
|
|
|
|
|
$smarty->assign('name',$fullnames);
|
|
|
|
|
|
|
|
|
|
|
|
$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st');
|
|
|
|
|
|
$smarty->assign('address',$addr);
|
|
|
|
|
|
|
|
|
|
|
|
$types = array(
|
|
|
|
|
|
array( 'home phone', 'cell phone', 'e-mail'),
|
|
|
|
|
|
array( 'home phone', 'web'),
|
|
|
|
|
|
array( 'cell phone')
|
|
|
|
|
|
);
|
|
|
|
|
|
$smarty->assign('contact_type', $types);
|
|
|
|
|
|
|
|
|
|
|
|
$info = array(
|
|
|
|
|
|
array('555-555-5555', '666-555-5555', 'john@myexample.com'),
|
|
|
|
|
|
array( '123-456-4', 'www.example.com'),
|
|
|
|
|
|
array( '0457878')
|
|
|
|
|
|
);
|
|
|
|
|
|
$smarty->assign('contact_info', $info);
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{*
|
|
|
|
|
|
Sections k<>nnen unbegrenzt tief verschachtelt werden. Mit
|
|
|
|
|
|
verschachtelten 'sections' k<>nnen Sie auf komplexe Datenstrukturen
|
|
|
|
|
|
zugreifen (wie zum Beispiel multidimensionale Arrays). Im folgenden
|
|
|
|
|
|
Beispiel ist $contact_type[customer] ein Array mit Kontakttypen des
|
|
|
|
|
|
aktuellen Kunden.
|
|
|
|
|
|
*}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{section name=customer loop=$custid}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<hr />
|
|
|
|
|
|
id: {$custid[customer]}<br />
|
|
|
|
|
|
name: {$name[customer]}<br />
|
|
|
|
|
|
address: {$address[customer]}<br />
|
|
|
|
|
|
{section name=contact loop=$contact_type[customer]}
|
|
|
|
|
|
{$contact_type[customer][contact]}: {$contact_info[customer][contact]}<br />
|
|
|
|
|
|
{/section}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{/section}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<hr />
|
|
|
|
|
|
id: 1000<br />
|
|
|
|
|
|
name: John Smith<br />
|
|
|
|
|
|
address: 253 N 45th<br />
|
|
|
|
|
|
home phone: 555-555-5555<br />
|
|
|
|
|
|
cell phone: 666-555-5555<br />
|
|
|
|
|
|
e-mail: john@myexample.com<br />
|
|
|
|
|
|
<hr />
|
|
|
|
|
|
id: 1001<br />
|
|
|
|
|
|
name: Jack Jones<br />
|
|
|
|
|
|
address: 417 Mulberry ln<br />
|
|
|
|
|
|
home phone: 123-456-4<br />
|
|
|
|
|
|
web: www.example.com<br />
|
|
|
|
|
|
<hr />
|
|
|
|
|
|
id: 1002<br />
|
|
|
|
|
|
name: Jane Munson<br />
|
|
|
|
|
|
address: 5605 apple st<br />
|
|
|
|
|
|
cell phone: 0457878<br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>sections und assoziative Arrays</title>
|
|
|
|
|
|
<programlisting role="php">
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
$data = array(
|
|
|
|
|
|
array('name' => 'John Smith', 'home' => '555-555-5555',
|
|
|
|
|
|
'cell' => '666-555-5555', 'email' => 'john@myexample.com'),
|
|
|
|
|
|
array('name' => 'Jack Jones', 'home' => '777-555-5555',
|
|
|
|
|
|
'cell' => '888-555-5555', 'email' => 'jack@myexample.com'),
|
|
|
|
|
|
array('name' => 'Jane Munson', 'home' => '000-555-5555',
|
|
|
|
|
|
'cell' => '123456', 'email' => 'jane@myexample.com')
|
|
|
|
|
|
);
|
|
|
|
|
|
$smarty->assign('contacts',$data);
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{*
|
|
|
|
|
|
Dies ist ein Beispiel wie man einen assoziativen Array in einer
|
|
|
|
|
|
'section' ausgeben kann.
|
|
|
|
|
|
*}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{section name=customer loop=$contacts}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<p>
|
|
|
|
|
|
name: {$contacts[customer].name}<br />
|
|
|
|
|
|
home: {$contacts[customer].home}<br />
|
|
|
|
|
|
cell: {$contacts[customer].cell}<br />
|
|
|
|
|
|
e-mail: {$contacts[customer].email}
|
|
|
|
|
|
</p>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{/section}
|
|
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
{* Anm. d. <20>bersetzers: Oft ist die Anwendung von 'foreach' k<>rzer. *}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
|
|
|
|
|
{foreach item=customer from=$contacts}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<p>
|
|
|
|
|
|
name: {$customer.name}<br />
|
|
|
|
|
|
home: {$customer.home}<br />
|
|
|
|
|
|
cell: {$customer.cell}<br />
|
|
|
|
|
|
e-mail: {$customer.email}
|
|
|
|
|
|
</p>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{/foreach}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<p>
|
|
|
|
|
|
name: John Smith<br />
|
|
|
|
|
|
home: 555-555-5555<br />
|
|
|
|
|
|
cell: 555-555-5555<br />
|
|
|
|
|
|
e-mail: john@mydomain.com
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
name: Jack Jones<br />
|
|
|
|
|
|
home phone: 555-555-5555<br />
|
|
|
|
|
|
cell phone: 555-555-5555<br />
|
|
|
|
|
|
e-mail: jack@mydomain.com
|
|
|
|
|
|
<p>
|
|
|
|
|
|
name: Jane Munson<br />
|
|
|
|
|
|
home phone: 555-555-5555<br />
|
|
|
|
|
|
cell phone: 555-555-5555<br />
|
|
|
|
|
|
e-mail: jane@mydomain.com
|
|
|
|
|
|
</p>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>sectionelse</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{*
|
|
|
|
|
|
sectionelse wird aufgerufen, wenn keine $custid Werte vorhanden sind
|
|
|
|
|
|
*}
|
|
|
|
|
|
{section name=customer loop=$custid}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
id: {$custid[customer]}<br>
|
|
|
|
|
|
{sectionelse}
|
|
|
|
|
|
keine Werte in $custid gefunden
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Die Eigenschaften der 'section' werden in besonderen Variablen
|
|
|
|
|
|
abgelegt. Diese sind wie folgt aufgebaut: <link
|
|
|
|
|
|
linkend="language.variables.smarty.loops">{$smarty.section.sectionname.varname}</link>
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<note>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Bermerkung: Seit Smarty 1.5.0 hat sich die Syntax der 'section'
|
|
|
|
|
|
Eigenschaften von {%sectionname.varname%} zu
|
|
|
|
|
|
{$smarty.section.sectionname.varname} ge<67>ndert. Die alte Syntax
|
|
|
|
|
|
wird noch immer unterst<73>tzt, die Dokumentation erw<72>hnt jedoch nur
|
|
|
|
|
|
noch die neue Schreibweise.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
</note>
|
|
|
|
|
|
<sect2 id="section.property.index">
|
|
|
|
|
|
<title>index</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
'index' wird verwendet, um den aktuellen Schleifen-Index
|
|
|
|
|
|
anzuzeigen. Er startet bei 0 (beziehungsweise der definierten
|
|
|
|
|
|
Startposition) und inkrementiert in 1-er Schritten (beziehungsweise
|
|
|
|
|
|
der definierten Schrittgr<67>sse).
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<note>
|
|
|
|
|
|
<title>Technische Bemerkung</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Wenn 'step' und 'start' nicht <20>bergeben werden, verh<72>lt sich der
|
|
|
|
|
|
Wert wie die 'section'-Eigenschaft 'iteration', ausser dass er bei
|
|
|
|
|
|
0 anstatt 1 beginnt.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
</note>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>'section'-Eigenschaft 'index'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid}
|
|
|
|
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br />
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
0 id: 1000<br />
|
|
|
|
|
|
1 id: 1001<br />
|
|
|
|
|
|
2 id: 1002<br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.index.prev">
|
|
|
|
|
|
<title>index_prev</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
'index_prev' wird verwendet um den vorhergehenden Schleifen-Index
|
|
|
|
|
|
auszugeben. Bei der ersten Iteration ist dieser Wert -1.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>section'-Eigenschaft 'index_prev'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid}
|
|
|
|
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|
|
|
|
|
{* zur Information, $custid[customer.index] und $custid[customer] bedeuten das selbe *}
|
|
|
|
|
|
{if $custid[customer.index_prev] ne $custid[customer.index]}
|
|
|
|
|
|
Die Kundennummer hat sich ge<67>ndert.<br>
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
0 id: 1000<br>
|
|
|
|
|
|
Die Kundennummer hat sich ge<67>ndert.<br>
|
|
|
|
|
|
1 id: 1001<br>
|
|
|
|
|
|
Die Kundennummer hat sich ge<67>ndert.<br>
|
|
|
|
|
|
2 id: 1002<br>
|
|
|
|
|
|
Die Kundennummer hat sich ge<67>ndert.<br>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.index.next">
|
|
|
|
|
|
<title>index_next</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
'index_next' wird verwendet um den n<>chsten 'loop'-Index
|
|
|
|
|
|
auszugeben. Bei der letzten Iteration ist dieser Wert um 1 gr<67>sser
|
|
|
|
|
|
als der aktuelle 'loop'-Index (inklusive dem definierten 'step'
|
|
|
|
|
|
Wert).
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>section'-Eigenschaft 'index_next'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid}
|
|
|
|
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|
|
|
|
|
{* zur Information, $custid[customer.index] und $custid[customer] bedeuten das selbe *}
|
|
|
|
|
|
{if $custid[customer.index_next] ne $custid[customer.index]}
|
|
|
|
|
|
Die Kundennummer wird sich <20>ndern.<br>
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
0 id: 1000<br>
|
|
|
|
|
|
Die Kundennummer wird sich <20>ndern.<br>
|
|
|
|
|
|
1 id: 1001<br>
|
|
|
|
|
|
Die Kundennummer wird sich <20>ndern.<br>
|
|
|
|
|
|
2 id: 1002<br>
|
|
|
|
|
|
Die Kundennummer wird sich <20>ndern.<br>
|
|
|
|
|
|
]]<5D>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.iteration">
|
|
|
|
|
|
<title>iteration</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
'iteration' wird verwendet um die aktuelle Iteration auszugeben.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Bemerkung: Die Eigenschaften 'start', 'step' und 'max'
|
|
|
|
|
|
beeinflussen 'iteration' nicht, die Eigenschaft 'index' jedoch
|
|
|
|
|
|
schon. 'iteration' startet im gegensatz zu 'index' bei 1. 'rownum'
|
|
|
|
|
|
ist ein Alias f<>r 'iteration' und arbeitet identisch.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>'section'-Eigenschaft 'iteration'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid start=5 step=2}
|
|
|
|
|
|
aktuelle loop iteration: {$smarty.section.customer.iteration}<br>
|
|
|
|
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|
|
|
|
|
{* zur Information, $custid[customer.index] und $custid[customer] bedeuten das gleiche *}
|
|
|
|
|
|
{if $custid[customer.index_next] ne $custid[customer.index]}
|
|
|
|
|
|
Die Kundennummer wird sich <20>ndern.<br>
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
aktuelle loop iteration: 1
|
|
|
|
|
|
5 id: 1000<br>
|
|
|
|
|
|
Die Kundennummer wird sich <20>ndern.<br>
|
|
|
|
|
|
aktuelle loop iteration: 2
|
|
|
|
|
|
7 id: 1001<br>
|
|
|
|
|
|
Die Kundennummer wird sich <20>ndern.<br>
|
|
|
|
|
|
aktuelle loop iteration: 3
|
|
|
|
|
|
9 id: 1002<br>
|
|
|
|
|
|
Die Kundennummer wird sich <20>ndern.<br>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.first">
|
|
|
|
|
|
<title>first</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
'first' ist 'true', wenn die aktuelle Iteration die erste dieser
|
|
|
|
|
|
'section' ist.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>'section'-Eigenschaft 'first'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid}
|
|
|
|
|
|
{if $smarty.section.customer.first}
|
|
|
|
|
|
<table>
|
|
|
|
|
|
{/if}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<tr><td>{$smarty.section.customer.index} id:
|
|
|
|
|
|
{$custid[customer]}</td></tr>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
{if $smarty.section.customer.last}
|
|
|
|
|
|
</table>
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<table>
|
|
|
|
|
|
<tr><td>0 id: 1000</td></tr>
|
|
|
|
|
|
<tr><td>1 id: 1001</td></tr>
|
|
|
|
|
|
<tr><td>2 id: 1002</td></tr>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.last">
|
|
|
|
|
|
<title>last</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
'last' ist 'true' wenn die aktuelle Iteration die letzte dieser
|
|
|
|
|
|
'section' ist.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>'section'-Eigenschaft 'last'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid}
|
|
|
|
|
|
{if $smarty.section.customer.first}
|
|
|
|
|
|
<table>
|
|
|
|
|
|
{/if}
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
<tr><td>{$smarty.section.customer.index} id:
|
|
|
|
|
|
{$custid[customer]}</td></tr>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
|
2005-06-24 09:02:38 +00:00
|
|
|
|
{if $smarty.section.customer.last}
|
|
|
|
|
|
</table>
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<table>
|
|
|
|
|
|
<tr><td>0 id: 1000</td></tr>
|
|
|
|
|
|
<tr><td>1 id: 1001</td></tr>
|
|
|
|
|
|
<tr><td>2 id: 1002</td></tr>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.rownum">
|
|
|
|
|
|
<title>rownum</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
'rownum' wird verwendet um die aktuelle Iteration (startend bei 1)
|
|
|
|
|
|
auszugeben. 'rownum' ist ein Alias f<>r 'iteration' und arbeitet
|
|
|
|
|
|
identisch.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>'section'-Eigenschaft 'rownum'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
2004-04-13 08:46:28 +00:00
|
|
|
|
{section name=customer loop=$custid}
|
2005-06-24 09:02:38 +00:00
|
|
|
|
{$smarty.section.customer.rownum} id: {$custid[customer]}<br />
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
1 id: 1000<br />
|
|
|
|
|
|
2 id: 1001<br />
|
|
|
|
|
|
3 id: 1002<br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.loop">
|
|
|
|
|
|
<title>loop</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
'loop' wird verwendet, um die Nummer letzte Iteration der 'section'
|
|
|
|
|
|
auszugeben. Dieser Wert kann inner- und ausserhalb der 'section'
|
|
|
|
|
|
verwendet werden.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>'section'-Eigenschaft 'loop'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid}
|
|
|
|
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br />
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
|
|
|
|
|
|
Es wurden {$smarty.section.customer.loop} Kunden angezeigt.
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
0 id: 1000<br />
|
|
|
|
|
|
1 id: 1001<br />
|
|
|
|
|
|
2 id: 1002<br />
|
|
|
|
|
|
|
|
|
|
|
|
Es wurden 3 Kunden angezeigt.
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.show">
|
|
|
|
|
|
<title>show</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
<emphasis>show</emphasis> kann die Werte 'true' oder 'false' haben.
|
|
|
|
|
|
Falls der Wert 'true' ist, wird die 'section' angezeigt. Falls der
|
|
|
|
|
|
Wert 'false' ist, wird die 'section' - ausser dem 'sectionelse' -
|
|
|
|
|
|
nicht ausgegeben.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>'section'-Eigenschaft 'show'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid show=$show_customer_info}
|
|
|
|
|
|
{$smarty.section.customer.rownum} id: {$custid[customer]}<br />
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
|
|
|
|
|
|
{if $smarty.section.customer.show}
|
|
|
|
|
|
die 'section' wurde angezeigt
|
|
|
|
|
|
{else}
|
|
|
|
|
|
die 'section' wurde nicht angezeigt
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
1 id: 1000<br />
|
|
|
|
|
|
2 id: 1001<br />
|
|
|
|
|
|
3 id: 1002<br />
|
|
|
|
|
|
|
|
|
|
|
|
die 'section' wurde angezeigt
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="section.property.total">
|
|
|
|
|
|
<title>total</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Wird verwendet um die Anzahl der durchlaufenen Iterationen einer
|
|
|
|
|
|
'section' auszugeben. Kann innerhalb oder ausserhalb der 'section'
|
|
|
|
|
|
verwendet werden.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>'section'-Eigenschaft 'total'</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{section name=customer loop=$custid step=2}
|
|
|
|
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|
|
|
|
|
{/section}
|
|
|
|
|
|
|
|
|
|
|
|
Es wurden {$smarty.section.customer.total} Kunden angezeigt.
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ausgabe des obigen Beispiels:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
0 id: 1000<br>
|
|
|
|
|
|
2 id: 1001<br>
|
|
|
|
|
|
4 id: 1002<br>
|
|
|
|
|
|
|
|
|
|
|
|
Es wurden 3 Kunden angezeigt.
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
2004-04-13 08:46:28 +00:00
|
|
|
|
</sect1>
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
|
|
Local variables:
|
|
|
|
|
|
mode: sgml
|
|
|
|
|
|
sgml-omittag:t
|
|
|
|
|
|
sgml-shorttag:t
|
|
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
|
|
sgml-indent-step:1
|
|
|
|
|
|
sgml-indent-data:t
|
|
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
|
|
sgml-parent-document:nil
|
|
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
|
|
End:
|
|
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
|
|
vi: ts=1 sw=1
|
2004-07-16 14:32:31 +00:00
|
|
|
|
-->
|